py
is not an environment variable, it's an executable that, for me at least, is located in your Windows directory (C:\Windows\
for me).
So, enter py
or py.exe
in your command prompt, and Python Launcher will run Python.
As you probably know, when you enter something into the command prompt, it will search all the directories in the PATH environment variable for a matching executable. It will execute the first one it finds, and stop the search. The Windows directory is in your PATH.
Help output for py.exe
:
C:\Users\Admin>py -h
Python Launcher for Windows Version 3.7.2150.1013
usage:
py [launcher-args] [python-args] script [script-args]
Launcher arguments:
-2 : Launch the latest Python 2.x version
-3 : Launch the latest Python 3.x version
-X.Y : Launch the specified Python version
The above all default to 64 bit if a matching 64 bit python is present.
-X.Y-32: Launch the specified 32bit Python version
-X-32 : Launch the latest 32bit Python X version
-X.Y-64: Launch the specified 64bit Python version
-X-64 : Launch the latest 64bit Python X version
-0 --list : List the available pythons
-0p --list-paths : List with paths
[...]
Thanks for this answer, path variables have always been a confusing subject. Its nice to get an idea of what happens in the back end! – Jack – 2019-12-11T17:48:15.277