0

I tried to print the "Hello World" in VSCode Terminal and received this message "The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. "

I've already installed python interpreter, adding evironment variables and WHEN I ATTEMPTED TO RUN MY PYTHON FILE VIA THE COMMAND PROMPT it printed without any problem (including printing lists or performing functions).

I've also checked python in the command and it replies version 3.8.5, however PowerShell keeps denying and appear the "not recognized" issue, no matter restarting the computer.

Can anyone help me with this problem? P/s: not only Python files, but my cpp files with C++ programming also have similar problems. I've installed MinGW and the program still can't run.

joseleii
  • 9
  • 1
  • 3
  • In a console, enter $ whereis python – g-radam Sep 02 '20 at 10:49
  • Does this answer your question? [VSCode: The term 'python' is not recognized...but py works](https://stackoverflow.com/questions/52332554/vscode-the-term-python-is-not-recognized-but-py-works) – g-radam Sep 02 '20 at 10:50

1 Answers1

0

From your description, do you mean the python command can be recognized in cmd both in VSCode and out of VSCode and can not be recognized in the PowerShell both in VSCode and out of VSCode?

If it's right, can you do these actions out of VSCode?

Step1: Open cmd type in 'where python' to find out the location of python which you are using as you described you can run python in cmd.

Step2: Open PowerShell type in 'get-command python' to check whether can you find python in PowerShell. And as you described, you should not get the location of the python command.

Step3: Then copy the path you get in step1 and enter into it in PowerShell, then type 'python' to check what will you get.

Step4: In Step3 you should get the python command work. And this means python was installed correctly, but your PowerShell can not find it. This is because your system environment path was changed temporarily in your PowerShell.

Step5: Enter into this location: C:\Users{UserName}\Documents\WindowsPowerShell, you can find 'profile.ps1' and 'Microsoft.PowerShell_profile.ps1'. Clear them.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13