Repository navigation
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]
- 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
astrowonk commentedon Jan 9, 2020
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 commentedon Jan 9, 2020
I imagine this was introduced in #8259. Perhaps around here
karrtikr commentedon 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.ympaik87 commentedon Jan 10, 2020
dang... I've been looking for a fix for this issue for days. This is a very crucial bug for Python developers
astrowonk commentedon Jan 10, 2020
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 commentedon 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 commentedon Jan 10, 2020
Yeah, I can't explain the -, when I run:
conda run -n base python ~/.vscode/extensions/ms-python.python-2020.1.57204/pythonFiles/interpreterInfo.pyon 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 commentedon Jan 10, 2020
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 commentedon Jan 10, 2020
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 commentedon Jan 10, 2020
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 commentedon Jan 20, 2020
Can you see if the latest version of the extension fixes the issue for you?
astrowonk commentedon Jan 21, 2020
The problem went away with the last python extension update. I assumed the conda run reversion solved it.
karrtikr commentedon Jan 21, 2020
Great. As the original issue is not reproducible, I am closing this in favor of #9490.