You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python Interpreter selection not working even though a version is being selected manually #18138
The Python Interpreter should be selected but none is being selected.
Actual behaviour
This is what happens when I try to select an interpreter. I can not click on the menu either it just does not do anything. When I click the arrow keys to move it, it glitches out like what is seen. Below is what I have tried.
-Reinstalling VSC and Python
-Trying Different Python Versions
Steps to reproduce
This started to happen when I booted up VSC yesterday I do not know how to reproduce it.
I just went to mess around with installing older versions and the select interpreter is no longer there and Python 3.10.1 64-Bit is now displayed but now I am getting an error that is saying Python is not installed. I tried all of the 2021 version but it started working when I tried v2020.1.57204.
Can you see what you get when you run "C:\Program files\Python310\python.exe" %USERPROFILE%\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py and see what you get? it should print a JSON with some data about the python.
If it is printing out JSON, can you set the python logging level in settings to debug and restart and share the entire log:
Run this command, from the same prompt:
C:\Users\Christopher\AppData\Local\Programs\Python\Python310\python.exe "c:\Users\Christopher.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\interpreterInfo.py"
From what I can tell, this error Error: spawn cmd.exe ENOENT is due to VS Code not being able to find cmd.exe. Can you make sure that the path printed out by set ComSpec, matches the location of cmd.exe? Error: spawn cmd.exe ENOENT is the cause of why the extension is not allowing you to pick anything.
cmd.exe is located in my C:\Windows\System32\ the one on set ComSpec is a lowercase s I'm assuming that might be causing the problem then. If that's the case then how would I go about fixing that?
Unless you have enabled case sensitive paths on windows that should not be causing this. I don't think that is the issue.
What do you get when you run set PATH?
To summarize the problem, In the extension we run python using cmd on windows to check if it is a valid python and extract some info about it. In this issue, node was failing to run cmd.exe, because it was not able to find it. This can happen for two reasons: 1) invalid path in ComSpec, 2) system32 got removed from PATH. Both of these can happen when users manually change environment variables or install software that changes environment variables.
@cjcocokrisps you can use the environments variable editor in this comment #18138 (comment) . to fix your problem. make sure that system32 is at the top of the list:
Activity
cjcocokrisp commentedon Dec 8, 2021
I just went to mess around with installing older versions and the select interpreter is no longer there and Python 3.10.1 64-Bit is now displayed but now I am getting an error that is saying Python is not installed. I tried all of the 2021 version but it started working when I tried v2020.1.57204.
karthiknadig commentedon Dec 9, 2021
Can you see what you get when you run
"C:\Program files\Python310\python.exe" %USERPROFILE%\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.pyand see what you get? it should print a JSON with some data about the python.If it is printing out JSON, can you set the python logging level in settings to debug and restart and share the entire log:

cjcocokrisp commentedon Dec 9, 2021
Is this correct?
karthiknadig commentedon Dec 9, 2021
@cjcocokrisps that seems to be right can you share the full logs.
cjcocokrisp commentedon Dec 9, 2021
how do i get that?
karthiknadig commentedon Dec 9, 2021
Ensure that logging is set to debug:

Reload VS Code, using the

Developer: reload window command:Open a Python file, and wait for the extension to load. Repro the problem, then copy paste the contents of the text here:

cjcocokrisp commentedon Dec 9, 2021
karthiknadig commentedon Dec 9, 2021
Can you try running this from the terminal? The logs seem to suggest this is failing to run.
cjcocokrisp commentedon Dec 9, 2021
6 remaining items
karthiknadig commentedon Dec 9, 2021
Run this command, from the same prompt:
C:\Users\Christopher\AppData\Local\Programs\Python\Python310\python.exe "c:\Users\Christopher.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\interpreterInfo.py"
cjcocokrisp commentedon Dec 9, 2021
Probably input something wrong?
karthiknadig commentedon Dec 9, 2021
You are missing a
\before.vscode.cjcocokrisp commentedon Dec 9, 2021
karthiknadig commentedon Dec 9, 2021
From what I can tell, this error
Error: spawn cmd.exe ENOENTis due to VS Code not being able to findcmd.exe. Can you make sure that the path printed out byset ComSpec, matches the location of cmd.exe?Error: spawn cmd.exe ENOENTis the cause of why the extension is not allowing you to pick anything.cjcocokrisp commentedon Dec 9, 2021
cmd.exeis located in myC:\Windows\System32\the one onset ComSpecis a lowercase s I'm assuming that might be causing the problem then. If that's the case then how would I go about fixing that?karthiknadig commentedon Dec 9, 2021
Unless you have enabled case sensitive paths on windows that should not be causing this. I don't think that is the issue.
What do you get when you run
set PATH?If you really want to try it, see this:

cjcocokrisp commentedon Dec 9, 2021
karthiknadig commentedon Dec 9, 2021
@cjcocokrisps Found the problem, your PATH looks wrong. This is what it typically looks like:

See that
C:\Windows\System32is the first entry. I am not sure how it got this way, but this can break a lot of things on Windows.You can use the environments variable editor to fix your problem. make sure that system32 is at the top of the list:

Fix that, then close and re-open all instances of VS Code.
I am closing this issue since it is not a python extension issue or VS code issue. Looks like some how PATH got overwritten.
karthiknadig commentedon Dec 9, 2021
To summarize the problem, In the extension we run
pythonusingcmdon windows to check if it is a valid python and extract some info about it. In this issue, node was failing to runcmd.exe, because it was not able to find it. This can happen for two reasons: 1) invalid path inComSpec, 2)system32got removed fromPATH. Both of these can happen when users manually change environment variables or install software that changes environment variables.cjcocokrisp commentedon Dec 9, 2021
Thanks for the help.
karthiknadig commentedon Dec 9, 2021
@cjcocokrisps you can use the environments variable editor in this comment #18138 (comment) . to fix your problem. make sure that system32 is at the top of the list:

cjcocokrisp commentedon Dec 9, 2021
Gotcha thanks again.