r/learnpython • • Jun 12 '24

Python works, "py" doesn't

I'm running a windows 10 machine with Python 3.12 installed. For some reason the 'python' command works fine, but 'py' gets me "'py' is not recognized as an internal or external command, operable program or batch file."

I have python installed here: C:\Users[username]\AppData\Local\Programs\Python\Python312

And the python launcher installed here: C:\Windows\py.exe

I've added both locations to my PATH, restarted the machine, but still doesn't work.

Any help is appreciated.

0 Upvotes

35 comments sorted by

View all comments

4

u/Ok_Concert5918 Jun 12 '24

Then just use Python. It’s how it works for everything else. Or write an alias in the terminal.

3

u/Fred776 Jun 12 '24

py is the recommended approach on Windows these days and it should work. It's particularly useful if you need to have multiple Python versions installed.

It's just an entry point though. Once you have set up a venv corresponding to a particular python version, you would work in that and use python.

2

u/Ok_Concert5918 Jun 12 '24

I use pyenv so the shims take care of that.