question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot detect and python interpreters; reopening of #5455

See original GitHub issue

My system still cannot detect instances of the python interpreter. This is a re-opening of bug 5455 which was closed and locked for inactivity. Sorry for the delay.

Environment data

  • VS Code version: 1.36.1
  • Extension version (available under the Extensions sidebar): 2019.6.24221
  • OS and version: Mac OS Mojave 10.14.5
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv
  • Relevant/affected Python packages and their versions: All
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): None

Expected behaviour

Python interpreters are detected

Actual behaviour

Python interpreters are NOT detected

Steps to reproduce:

  1. Create python package
  2. Create a virtualenv in package
  3. Launch score
  4. Attempt to select interpreter

I used the final version of interpreterInfo.py from #5455 to gather these logs

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

[log.log](https://github.com/microsoft/vscode-python/files/3393584/log.log)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

[devTools.log](https://github.com/microsoft/vscode-python/files/3393587/devTools.log)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
mrbell321commented, Jul 26, 2019

Ah-HA! That was it! I don’t know why grep didn’t find this… I don’t remember ever creating this file and there’s a copy in several projects, so it was probably cloned from something.

Thanks for walking me through this!

1reaction
mrbell321commented, Jul 16, 2019

I did a bit of digging through minified extension.js javascript and found where python is being called. The stderr stream is being merged to std out so JS is trying to JSON.parse an error message(you probably already knew this part). So I set about trying to re-create the problem. When I run from the command line: /Users/tylerbell/code/TraceUpdater/venv/bin/python3.7 -W '"once' /Users/tylerbell/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/interpreterInfo.py the response matches the error I am seeing: Invalid -W option ignored: invalid action: '"once' {"versionInfo": [3, 7, 3, "final"], "sysPrefix": "/Users/tylerbell/code/TraceUpdater/venv/bin/..", "version": "3.7.3 (default, Mar 27 2019, 09:23:15) \n[Clang 10.0.1 (clang-1001.0.46.3)]", "is64Bit": true}

Since the extension.js merges the stderr into stdout, it tries to parse everything as JSON and obviously fails when there is something not JSON, like an error message.

So the root cause question is, why is vscode trying to set the warning level to `‘"once’. The javascript is too obfuscated for me to follow.

The other question is, if you’re attempting to parse output as JSON, why would you merge in stderr? Seems like a recipe for failure.(but then again, silent passing could be worse)

I did manage to hack my way past the problem by changing the offending javascript to: const t = await this.procService.exec(this.pythonPath, [e], { mergeStdOutErr: false }).then(e => e.stdout.trim());

However, other vscode/python operations have similar issues. This is what I see when trying to debug my code: cd /Users/tylerbell/code/TraceUpdater ; env 'PYTHONPATH=$PTYHONPATH:' 'PYTHONWARNINGS="once' PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/tylerbell/code/TraceUpdater/venv/bin/python3.7 /Users/tylerbell/.vscode/extensions/ms-python.python-2019.6.24221/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 52098 /Users/tylerbell/code/TraceUpdater/.vscode/launch.json

Note 'PYTHONWARNINGS="once' and the misspelled 'PYTHONPATH=$PTYHONPATH:'

I do not see these errors when launching loading my venv from the command line and launching the app and pycharm doesn’t have these issues either. it seems specific to vscode and/or the python plugin.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot detect and python interpreters · Issue #5455 - GitHub
Install VS Code; Install python extension; Try to set the interpreter(none is found and 'hardcoding' it does not seem to have any effect)....
Read more >
Visual Studio Code cannot recognize Python interpreter
In VS Code, open the Settings with (Ctrl+,) then search settings for "Interpreter." There will an option for "Python: Default Interpreter Path. ...
Read more >
Vscode Does Not Seem To Accept Interpreter From Virtual ...
My system still cannot detect instances of the python interpreter. This is a reopening of bug 5455 which was closed and locked for...
Read more >
Configure a Python interpreter | PyCharm Documentation
Press Ctrl+Alt+S to open the IDE settings and select Project <project name> | Python Interpreter. · Expand the list of the available interpreters ......
Read more >
Using Python environments in VS Code
direnv folder for direnv under the workspace (project) folder. You can also manually specify an interpreter if Visual Studio Code doesn't locate your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found