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.

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

See original GitHub issue

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 #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.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
karrtikrcommented, 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.

1reaction
ympaik87commented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Interpreter Not Found VSCode - Stack Overflow
3 Answers 3 · Ctrl+Shift+P, Preferences: Open Settings(JSON) · Copy your python path · Add line like this, paste and replace the path:...
Read more >
Changelog — Python 3.11.1 documentation
parse.urlparse() that causes certain port numbers containing whitespace, underscores, plus and minus signs, or non-ASCII digits to be incorrectly accepted.
Read more >
Error: A Python Interpreter Could not be Loaded
Solution. The current solution involves opening FME Workbench > Tools > FME Options > Translation. If you select the Dropdown menu for the ......
Read more >
Troubleshoot Python errors in Azure Functions - Microsoft Learn
The Python interpreter mismatches OS architecture. This mismatch is most likely caused by a 32-bit Python interpreter being installed on your 64 ...
Read more >
Tasks in Visual Studio Code
Select tsc: build or tsc: watch and VS Code will generate a tasks.json file. ... the selected Python interpreter used by the Python...
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