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 detected

See original GitHub issue

Environment data

  • VS Code version: 1.38.1
  • Extension version (available under the Extensions sidebar): 2019.9.34911
  • OS and version: Windows_NT x64 10.0 18362
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda3 3.7.4
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): Pipenv
  • Relevant/affected Python packages and their versions: Python itself.
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): N/A

Expected behaviour

Select Python Interpreter should show the current interpreter. which is already assigned in .vscode/settings.json like below.

{ "python.pythonPath": "C:\\Users\\Jaepil\\.virtualenvs\\likelion-WdsTZA1R\\Scripts\\python.exe" }

Actual behaviour

Select Python Interpreter warning is shown and the extension keeps telling me to select a python interpreter. Some of the virtualenvs are shown in the list but some are not. I don’t know what’s the difference.

Please see this screenshot: https://imgur.com/a/wflBshp

Why are some of the interpreters are shown while some of them are not?

Steps to reproduce:

I have absolutely no idea how this happened. All that I did was opening a new VSCode window while the other was still open. However, I did this several times before and it was all fine then.

Logs

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

User belongs to experiment group 'ShowPlayIcon - control'
User belongs to experiment group 'ShowExtensionSurveyPrompt - enabled'
Starting Jedi Python language engine.
> conda --version
> pyenv root
> python3.7 -c "import sys;print(sys.executable)"
> python3.6 -c "import sys;print(sys.executable)"
> python3 -c "import sys;print(sys.executable)"
> python2 -c "import sys;print(sys.executable)"
> python -c "import sys;print(sys.executable)"
> py -3.7 -c "import sys;print(sys.executable)"
> py -3.6 -c "import sys;print(sys.executable)"
> py -3 -c "import sys;print(sys.executable)"
> py -2 -c "import sys;print(sys.executable)"
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe -c "import sys;print(sys.executable)"
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> ~\Anaconda3\Scripts\conda.exe info --json
> ~\AppData\Local\Microsoft\WindowsApps\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\AppData\Local\Microsoft\WindowsApps\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\AppData\Local\Microsoft\WindowsApps\python3.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\AppData\Local\Microsoft\WindowsApps\python3.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> ~\Anaconda3\Scripts\conda.exe env list
> ~\.virtualenvs\20190117_informatics_contest-taotUAHV\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\20190117_informatics_contest-taotUAHV\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\KIS_Research-1sAPdYt-\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\KIS_Research-1sAPdYt-\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\PyTorchZeroToAll-hoWX9lIa\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\PyTorchZeroToAll-hoWX9lIa\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\System32-eU24dAeB\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\System32-eU24dAeB\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\WebScrapingWithPython_Notebook-Wh9dVbnF\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\WebScrapingWithPython_Notebook-Wh9dVbnF\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> ~\.virtualenvs\python-scraping-n26INho8\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\python-scraping-n26INho8\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\pytorch_tutorials-8nbdP8vq\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\pytorch_tutorials-8nbdP8vq\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\testproject-P1Q1RQ0U\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\testproject-P1Q1RQ0U\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\vid_scraper-gdpErQhb\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\vid_scraper-gdpErQhb\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\web1-Jti_MdSz\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\web1-Jti_MdSz\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> ~\Anaconda3\Scripts\conda.exe env list
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> pipenv --py
cwd: e:\VSCodeProjects\likelion
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.
> ~\Anaconda3\Scripts\conda.exe info --json
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> ~\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py
> pipenv --version
cwd: e:\VSCodeProjects\likelion
> pipenv --venv
cwd: e:\VSCodeProjects\likelion
> pipenv --py
cwd: e:\VSCodeProjects\likelion

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)

There was an error

console.ts:137 [Extension Host] Error Python Extension: 2019-09-17 02:20:13: Failed to parse interpreter information for 'C:\Users\Jaepil\.virtualenvs\likelion-WdsTZA1R\Scripts\python.exe' with JSON Traceback (most recent call last):
  File "c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\interpreterInfo.py", line 4, in <module>
    import json
ModuleNotFoundError: No module named 'json' SyntaxError: Unexpected token T in JSON at position 0    at JSON.parse (<anonymous>)    at p.getInterpreterInformation (c:\Users\Jaepil\.vscode\extensions\ms-python.python-2019.9.34911\out\client\extension.js:75:291605)

Tried to look into it but I have no clue where to even start. It is just beyond my programming capability.

Yes maybe I can forget with all the “lost” virtualenv interpreters and move on but I really want a solution for this.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:18

github_iconTop GitHub Comments

1reaction
DonJayamannecommented, Sep 17, 2019

Glad you were able to resolve this.

1reaction
jaepil-choicommented, Sep 17, 2019

@DonJayamanne Thanks to your help and assistance, I could pinpoint the cause of the problem. It was because of Anaconda python in the virtualenv, which no longer was a valid Python interpreter since my Anaconda base Python has been upgraded to 3.7.3.

I’m not 100% sure why this was broken but it seems like upgrading Anaconda’s base Python (whether by upgrading by conda upgrade conda or by re-installing anaconda) breaks previous virtualenvs that used previous version of Anaconda Python as an interpreter.

The weird behavior of Python not able to load even the simplest json package was due to these changes. Actually, it is unable to install any other packages since pip is also not working.

I don’t know how but I think that’s why VSCode hid this virtualenv because it is no longer valid.

I learned it the hard way: Don’t use Conda’s Python if you don’t need it. I was using it to replace pyenv since it’s not supported in Windows but that was a wrong choice I guess.

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, Python: Select Interpreter · Enter interpreter path – Find (or enter the path manually) enter image description here....
Read more >
Configure a Python interpreter | PyCharm Documentation
Do one of the following: Click the Python Interpreter selector and choose Add New Interpreter. Press Ctrl+Alt+S to open Settings/Preferences and ...
Read more >
vscode can't find python interpreter - Reddit
vscode can't find python interpreter · Type python --version in Terminal to check if you've installed python correctly; · Open Command Palette( ...
Read more >
Manage Python environments and interpreters - Visual Studio ...
If no environments appear, it means Visual Studio failed to detect any Python installations in standard locations. For example, you might have ...
Read more >
How to Set Default Python Interpreter in VS Code
2. Choose User > Extensions>Python > Python Path and paste the path that we copied earlier. Remember the path is not complete. So,...
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