I’ve been trying to setup my python workspace on vscode but the software doesn’t seem to pick up the fact that I have python installed, and keeps telling me to install python. I’ve tried manually adding the path of the .exe file but the "invalid interpreter prompt" shows up every single time. Just for proof of me having the correct path in the settings here’s a screenshot of the .json file and
the command prompts I used to obtain the path.
Question posted in Visual Studio Code
View the official documentation.
View the official documentation.
7
Answers
First, make sure you have the python extension installed.
Then follow the steps below to choose an interpreter for vscode:
Use Ctrl+Shift+P to open the command palette
search for
Python:Select Interpreter
(or click select interpreter in the lower right corner)If the panel shows an interpreter, select the available interpreter. If the panel doesn’t have an interpreter option. Please select the first item
Enter interpreter path
Then paste the full path to your
python.exe
(or go to explorer by selectingFind
and select yourpython.exe
)If it still fails, try installing the pre-release python extension.
For me, after investigating the problem in this issue, I found that the problem had to do with my
ComSpec
environment variable. This environment variable needs to be set toC:Windowssystem32cmd.exe
for the python extension to work.Make sure to restart after changing the environment variable for changes to take effect
On my device (VSCode 1.71.2, Python extension 2022.14.0) I could solve the problem by clearing the python interpreter setting.
For this, use Ctrl+Shift+P to open the command palette. Then, enter
Python: Clear Workspace Interpreter Setting
. On the next panel, select to delete all.After this, you should be able to select an interpreter by entering
Python:Select Interpreter
in the command palette.I tried all the suggestions above, none worked. I even tried reinstalling it, no luck.
What worked was downgrading to the previous version (in my case
v2022.12.1
) of the Python vscode extension then upgrading to the latest (which wasv2022.12.1
).Running VS Code as administrator helped with solving the invalid python interpreter problem.
what fixed it for me was going to settings -> search "inherit env" and disable it.
(macos)
Re-Create the virtual venv solved it