0

I seem to be having the opposite issue as this user in this question. I can run python successfully, but py does not work for me. Overall, this is not a big deal but when I try to run code in VS Code, I get the error below:

py: The term 'py' is not recognized as a name of a cmdlet, function, script file, or executable program.

How can I either make VScode run python or change my system to accept py?

When I first downloaded Python, it was not placed into the path but I was able to fix that. I also confirmed that VS Code has selected the correct interpreter for Python in the same place.

EDIT: IMAGES Path directory Path used in enviroment

Eric
  • 25
  • 4
  • What OS are you using?...either way this will come down to setting an alias for the command to operate with a different call...example: https://stackoverflow.com/a/13596981/8382028 – ViaTech Dec 10 '22 at 00:40
  • I have never once seen that python can be run with `py`. That seems the odd one out. – sweenish Dec 11 '22 at 00:34

1 Answers1

0

When you write "python" on CMD or Powershell, it checks the given keyword("python" here) in all the directories in Environment Variables.

In the case of python, the directory mentioned for python in Environment Variables > Path, you will find "python.exe" and not "py.exe".

So your cmd or PowerShell recognizes python and not py.

Ayushman Kumar
  • 113
  • 1
  • 12
  • 1
    Thanks for the help on this. I am sure it is very beginner but everything online seems to say "just add this line into path" or something similar and I am trying to understand the why for it. That makes a lot of sense. I attached two images to the original question and would love a bit more clarifying help if you are willing. One picture is the path I have in my environment and another is what that directory looks like. My question is if I were to change the highlighted "python" file to be "py" would that then start taking py as the command? I want to understand what file or app cmd looks at. – Eric Dec 11 '22 at 16:09
  • Yes certainly, it will work. – Ayushman Kumar Dec 12 '22 at 17:51