Problem
If you run Python in your terminal or shell, you may have realized that there are two ways to do so: using the “python
” command and using the “py
” command. What’s the difference?
Example
Say, you want to check your Python version. You can run both commands and the output is different!
Here’s using the “python
” command:
$ python -V 3.9.2
Here’s using the “py
” command:
$ py -V 3.8.5
You can see that running the two commands can execute different Python versions!
Difference “python” vs “py”
- The command
python
refers to the Python executable of the default Python installation. Technically, the path of this version is stored inside thePATH
environment variable where your OS will search for the executable when processing any command. - The command
py
refers to the Python launcher, a utility that’s automatically installed intoC:\Windows\
for any Python installation on Windows. All files in the Windows folder are accessible without needing to modify thePATH
environment variable. Thus, the Python launcher automatically delegates the work to the latest Python version installed in your environment. However, you can also specify the used installation by means of a flag argument such as inpy -3.6
to specify Python version 3.6.
Further Reading and References
Read more about the Python launcher in the docs and in this excellent SO post. Here’s an excerpt from the docs:
The Python launcher for Windows is a utility which aids in locating and executing of different Python versions. It allows scripts (or the command-line) to indicate a preference for a specific Python version, and will locate and execute that version.
Unlike the PATH
variable, the launcher will correctly select the most appropriate version of Python. It will prefer per-user installations over system-wide ones, and orders by language version rather than using the most recently installed version.

While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.