Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
astrowonk opened this issue Jan 9, 2020 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@astrowonk
Copy link

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 (ViewOutput, 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.

@astrowonk astrowonk added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Jan 9, 2020
@astrowonk
Copy link
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.

@astrowonk
Copy link
Author

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

@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Jan 9, 2020
@karrtikr
Copy link

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.

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Jan 10, 2020
@ympaik87
Copy link

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

@astrowonk
Copy link
Author

astrowonk commented Jan 10, 2020

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.

@karrtikr karrtikr removed the info-needed Issue requires more information from poster label Jan 10, 2020
@karrtikr
Copy link

karrtikr commented Jan 10, 2020

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.

@astrowonk
Copy link
Author

astrowonk commented Jan 10, 2020

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?

@karrtikr
Copy link

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.

@astrowonk
Copy link
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.

@karrtikr
Copy link

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.

@karrtikr
Copy link

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

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Jan 20, 2020
@astrowonk
Copy link
Author

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

@karrtikr
Copy link

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

@ghost ghost removed the triage label Jan 21, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants