Skip to content

Python interpreter not being recognized "No Python interpreter is selected" (JSON parsing fail) #9484

Description

Environment data

  • VS Code version: 1.41.1
  • Extension version (available under the Extensions sidebar): 2020.1.57204
  • OS and version: RHEL 7
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.2 (miniconda)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): XXX
  • Relevant/affected Python packages and their versions: XXX
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): language server

Expected behaviour

VS Code to recognize Python 3.7.2 from its location in /opt/miniconda/bin as it has always done

Actual behaviour

GUI and console claim that no interpreter selected. Debugger doesn't seem to run correctly.

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Launch VS Code. Open python file. VS Code prompts for python interperter. GUI pop-up does not list python 3.7 in /opt/miniconda/bin as it did previously.

Logs

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

Starting Microsoft Python language server.
Starting Microsoft Python language server.
> conda run -n base python ~/.vscode/extensions/ms-python.python-2020.1.57204/pythonFiles/interpreterInfo.py
> conda run -n base python ~/.vscode/extensions/ms-python.python-2020.1.57204/pythonFiles/interpreterInfo.py
> conda run -n base python ~/.vscode/extensions/ms-python.python-2020.1.57204/pythonFiles/interpreterInfo.py
> conda run -n base python ~/.vscode/extensions/ms-python.python-2020.1.57204/pythonFiles/interpreterInfo.py
> conda run -n base python -c "import sys;print(sys.prefix)"
cwd: ~/checkouts
> conda run -n base python -c "import sys;print(sys.prefix)"
cwd: ~/checkouts
> conda run -n base python -c "import sys;print(sys.executable)"
cwd: ~/checkouts
> conda run -n base python -c "import sys;print(sys.executable)"
cwd: ~/checkouts
> conda run -n base python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: ~/checkouts
> conda run -n base python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: ~/checkouts
> conda run -n base python -m site --user-site
cwd: ~/checkouts
> conda run -n base python -m site --user-site
cwd: ~/checkouts
Diagnostic Code: InvalidPythonInterpreterDiagnostic, Message: No Python interpreter is selected. You need to select a Python interpreter to enable features such as IntelliSense, linting, and debugging.

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)

Error Python Extension: 2020-01-09 10:01:03: Failed to parse interpreter information for '/opt/miniconda/bin/python3.7' with JSON --timed out-- [SyntaxError: Unexpected number in JSON at position 1
	at JSON.parse (<anonymous>)
	at s.getInterpreterInformation (/home/mhuerta/.vscode/extensions/ms-python.python-2020.1.57204/out/client/extension.js:1:442879)
	at async getInterpreterInformation (/home/mhuerta/.vscode/extensions/ms-python.python-2020.1.57204/out/client/extension.js:75:1187651)
	at async Promise.all (index 0)
	at async C.collectInterpreterDetails (/home/mhuerta/.vscode/extensions/ms-python.python-2020.1.57204/out/client/extension.js:75:1194494)]

I can type conda run -n base python ~/.vscode/extensions/ms-python.python-2020.1.57204/pythonFiles/interpreterInfo.py on the command line and it returns:

{"versionInfo": [3, 7, 2, "final"], "sysPrefix": "/opt/miniconda", "version": "3.7.2 (default, Dec 29 2018, 06:19:36) \n[GCC 7.3.0]", "is64Bit": true}

so I'm not sure why that's problematic JSON.

Activity

  1. added
    triage-neededNeeds assignment to the proper sub-team
    bugIssue identified by VS Code Team member as probable bug
    on Jan 9, 2020
  2. astrowonk commented on Jan 9, 2020

    @astrowonk
    Author

    This problem is not present in 2019.11.50794 which I just reverted to. It appears to have been introduced in the latest version a few days ago. Failure to parse the interpreter json means that the debugger and other things aren't working either.

  3. astrowonk commented on Jan 9, 2020

    @astrowonk
    Author

    I imagine this was introduced in #8259. Perhaps around here

  4. ghost removed
    triage-neededNeeds assignment to the proper sub-team
    on Jan 9, 2020
  5. karrtikr commented on Jan 10, 2020

    @karrtikr

    Actually the JSON it returns is --timed out--, which is why parsing JSON failed. Can you always reproduce it, or does it times out only sometimes?

    We're reverting conda run #9490 so this should be fixed by Monday.

  6. ympaik87 commented on Jan 10, 2020

    @ympaik87

    dang... I've been looking for a fix for this issue for days. This is a very crucial bug for Python developers

  7. astrowonk commented on Jan 10, 2020

    @astrowonk
    Author

    Actually the JSON it returns is --timed out--, which is why parsing JSON failed. Can you always reproduce it, or does it times out only sometimes?

    We're reverting conda run #9490 so this should be fixed by Monday.

    It was happening every time, persisting across multiple restarts of code, reinstalling language server, reinstalling Python extension, etc. (I'm now running the old extension)

    It does say it timed out but it also says Unexpected number in JSON at position 1?

    Thanks for the response and quick reversion.

  8. karrtikr commented on Jan 10, 2020

    @karrtikr

    JSON parser does not expect - at the start of the JSON string which results in the error of syntax at position 1 is incorrect.

    Unfortunately I am not able to reproduce this on Windows. i will try it on Linux and will get back to you.

  9. astrowonk commented on Jan 10, 2020

    @astrowonk
    Author

    JSON parser does not expect - at the start of the JSON string which results in the error of syntax at position 1 is incorrect.

    Unfortunately I am not able to reproduce this on Windows. i will try it on Linux and will get back to you.

    Yeah, I can't explain the -, when I run:

    conda run -n base python ~/.vscode/extensions/ms-python.python-2020.1.57204/pythonFiles/interpreterInfo.py

    on the command line which is what it looks like it was doing, I don't see any dashes. I get back:
    {"versionInfo": [3, 7, 2, "final"], "sysPrefix": "/opt/miniconda", "version": "3.7.2 (default, Dec 29 2018, 06:19:36) \n[GCC 7.3.0]", "is64Bit": true}

    maybe it's the \n?

  10. karrtikr commented on Jan 10, 2020

    @karrtikr

    I see where you're confused. Command line returns the arguments just fine. But when the extension is doing that it's returning --timed out-- instead of the JSON you just pasted, which is where - is coming from.

  11. astrowonk commented on Jan 10, 2020

    @astrowonk
    Author

    Ah,ha! I see! So while it works in the command line, for some reason that command is not correctly generating the JSON inside of VS Code, instead it is timing out. So the JSON parser tries to parse a string, and dies.

  12. karrtikr commented on Jan 10, 2020

    @karrtikr

    Exactly. Unfortunately, I am not able to see why it times out in the extension while it does not when you run the command manually.

  13. karrtikr commented on Jan 20, 2020

    @karrtikr

    Can you see if the latest version of the extension fixes the issue for you?

  14. astrowonk commented on Jan 21, 2020

    @astrowonk
    Author

    The problem went away with the last python extension update. I assumed the conda run reversion solved it.

  15. karrtikr commented on Jan 21, 2020

    @karrtikr

    Great. As the original issue is not reproducible, I am closing this in favor of #9490.

  16. ghost removed on Jan 21, 2020
  17. locked as resolved and limited conversation to collaborators on Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions