0

When I try to do Ctrl + Alt + N on VS Code (to run the code), it gives me the following error:

[Running] python -u "c:\Users\myName\OneDrive\Documents\folderName\d.py"
'python' is not recognized as an internal or external command,
operable program or batch file.

I have already added python to the environment variables and even modified python by adding it to PATH as several users stated, but I still get this error. Also restarted several times, and even redownloaded VS Code and Python. I don't know why this is happening, it was working perfectly until yesterday when my run button in the top right corner disappeared and since then even that isn't being seen even though I have the coderunner extension. Also must note that when I type python into a command prompt i get the same error, but py works perfectly. Plus, my code will execute when I go to run and debug in vs code, but not when i do the shortcut. If you have a solution for the run button not showing up in the top right corner even for java, that would be great too!

peekay
  • 11
  • 2
  • it looks like python is not added to your path environment variables. do that and vs code will find it – se7en May 08 '23 at 16:28
  • 2
    show exactly what you added to your `PATH` and exactly where you python installation is located on your filesystem. – starball May 08 '23 at 17:23
  • @user i added the path to the python.exe file to my PATH – peekay May 08 '23 at 21:37
  • 3
    you're supposed to add the _directory containing_ the exe to your `PATH`- not the path to the exe itself. – starball May 08 '23 at 21:39
  • @user so would that be the same path that I was using but without the python.exe? – peekay May 08 '23 at 22:02
  • 2
    yes. and when I say "_show exactly what you added to your `PATH` and exactly where you python installation is located on your filesystem._", I mean full (absolute) paths. You still have not actually answered those questions. and you're supposed to [edit] clarifications into the question post instead of providing them in comments. – starball May 08 '23 at 22:04
  • @user finally worked thank you so much!! – peekay May 08 '23 at 22:07

1 Answers1

0

'python' is not recognized as an internal or external command, operable program or batch file.

The reason for this error is that the system cannot recognize the python command. You should add the path of the folder where the python interpreter is located to the system environment variable path.

In addition, if you use Code Runner, there are the following settings to control whether the triangle button in the upper right corner is displayed or not.

    "code-runner.showRunIconInEditorTitleMenu": true,

As a suggestion, the best extension to run python scripts in VS code is Python, as an official extension, it provides more features, including intellisense, debugging code, etc.

enter image description here

It would be better to follow this start document.

JialeDu
  • 6,021
  • 2
  • 5
  • 24