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

Show parent comments

3

u/shinitakunai Jun 12 '24

No, when you create a venv the python.exe interpreter gets copied inside the venv folder as well, so you can just call that one

-1

u/iamevpo Jun 12 '24

It's the same. Interpreter as your base installation, right? You do not really choose a python version number with venv, I think that's not an option.

4

u/cloudiimofo Jun 12 '24

You absolutely can set the version number to any you have installed. I have legacy apps using python 2 inside of the virtual environment.

1

u/xiongchiamiov xiongchiamiov Jun 13 '24

You don't really "set the version number". If you have multiple versions of python installed, you can install virtualenv in each one. And when you call it, virtualenv uses the version of Python it is associated with.

Compare this to pyenv, which will install arbitrary versions of python for you.