'VS Code can't find Python
I have a huge issue with VS Code since many weeks. One day VS Code didn't manage to run any python file. I have the message :
bash: C:/Users/rapha/AppData/Local/Programs/Python/Python38/python.exe: No such file or directory
I have uninstall Python and VS CODE many times to add properly python 3.8 to my windows path but I have always the error. Have you got any idea ?
Thank you very much
Solution 1:[1]
Go to the VS Code preferences, and under interpreter, you'll find Interpreter Path, so set that to the path of your python installation, restart VS Code, and you should be good.
Solution 2:[2]
I have installed VS code insider and it works perfectly. I'm happy. It doesn't fix the issue but it's a great alternative.
Edit : The issue came back
Solution 3:[3]
In VS Code, open the Settings with (Ctrl+,) then search settings for "Interpreter." There will an option for "Python: Default Interpreter Path." Set the location of your python.exe file. Open a new VS terminal with (Ctrl+Shift+`) to test the python command; you may need to restart VS Code.
I had trouble with VS being unable to locate python even though I could run python commands from any terminal opened from my computer (Windows Logo Key + cmd + Enter). I noticed that the Scripts folder was not installed on my python install, so I reinstalled python and followed the above steps. It worked for me.
VS Code has a python tutorial as well which includes a Select a Python Interpreter section (https://code.visualstudio.com/docs/python/python-tutorial).
Solution 4:[4]
I had this same problem, but I found a different solution;
in settings.json I had
"python.defaultInterpreterPath": "D:\Program Files\Python310\python.exe"
but even this was getting ignored for some reason!
So, I looked at $ENV:path in the powershell loaded in vscode, and the $ENV:path in the standard commandline powershell in windows, and they were different!
It seems that if you have a terminal open in VSCode, it remembers the $ENV from that terminal, even if you completely restart vscode or even if you reboot your computer.
What worked for me (by accident) is, close all terminal windows (and possibly anything else terminal/powershell related that's open) and give it another try!
If it still doesn't work, compare the $ENV:Path values again, and see if they're still different!
Solution 5:[5]
The Python interpreter was placed in a new location in the status bar. Just go to the corner and select the appropriate interpreter.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | OctopuSS7 |
| Solution 2 | |
| Solution 3 | |
| Solution 4 | Malendryn |
| Solution 5 | J.C. Gras |

