Python not found
Hello,
I am a beginner in programming and I am trying to practice using Visual Studio Code. I wrote a few lines of code to see if it worked after installing the Python extension. I read that I also needed the Code Runner extension for my program to work, and after installing it, the terminal displays "python is not found", even though it was working before I installed Code Runner.
If someone could help me, that would be great!
Thanks in advance
Configuration: Windows / Chrome 100.0.4896.127
I am a beginner in programming and I am trying to practice using Visual Studio Code. I wrote a few lines of code to see if it worked after installing the Python extension. I read that I also needed the Code Runner extension for my program to work, and after installing it, the terminal displays "python is not found", even though it was working before I installed Code Runner.
If someone could help me, that would be great!
Thanks in advance
Configuration: Windows / Chrome 100.0.4896.127
3 answers
-
ModeratorHello,
Generally speaking, a tool cannot guess where an executable is located. There are two options:- either you provide the absolute path to your python interpreter, and the tool doesn’t have to guess;
- or you provide the command name, and in this case, the tool needs to know where to look for it.
Let’s take an example. If you type the commandpython
in the MS-DOS commands, the corresponding executable is found only if it is located in one of the folders listed in the environment variablePATH
. It would be interesting to check if this point is working correctly to ensure that python is still installed and functional.
Maybe this discussion could help you. It seems that the variable$pythonPath
contains the path to your python interpreter, but that it may not be sufficient if that path contains spaces (which is probably your case). You then need to correct the Code Runner configuration as follows:
"code-runner.executorMap": { "python": "\"$pythonPath\" -u $fullFileName", }
If that doesn't work, you might try replacing"\"$pythonPath\"
with the absolute path ofpython.exe
, which you can find via MS-DOS commands using the commandwhere python
. You may need to escape the spaces and \ by preceding them with a \ (e.g.C:\\Users\\toto\\AppData\\Local\\Continuum\\anaconda3\\python.exe
).
Good luck!