Monday, April 8, 2013

py, the Python Launcher for Windows

By Vasudev Ram

py, or py.exe, is the name of a new(ish) Python Launcher for Windows, which was released as part of Python 3.x.

This is the PEP for py.

I tried out Py and it worked okay, for some basic uses.

It lets you launch a specific version of Python, either 2, or 3, or 2.x or 3.x. I tried using it to launch both Python 2.7.3 and Python 3.3.1.

C:\> py -V
Python 2.7.3
C:\> py -3 -V
Python 3.3.1
c:\Python33\Tools\Scripts> py -2 py.exe
c:\Python33\Tools\Scripts>py -2 cmd.exe

Here is the partial output of running the py --help command:
c:\Python33\Tools\Scripts>py --help
Python Launcher for Windows Version 3.3.1150.1013

usage: py [ launcher-arguments ] script [ script-arguments ]

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
-X.Y-32: Launch the specified 32bit Python version

- Vasudev Ram - Dancing Bison Enterprises


Brett Dixon said...

Didn't even know this existed! We have a python 2.x environment, do I have to install py3 to get this or is it a separate download somewhere? Will it work if I dont' have py3 installed at all?

Vasudev Ram said...

I am not sure but I think you may have to install Python 3 to get the py.exe utility; reason I think so is because I got to know about it from reading one of the What's New in Python 3.x posts.

I just did a search of my entire Python 2.7 directory (recursively) and did not find any py.exe command there.

Vasudev Ram said...

But who knows, it may get back-ported to Python 2 at some time, like many other Python 3 features are/have been.

Vinay Sajip said...

You don't need Python 3.3 to get the launcher, it's available in standalone form from

The launchwin versions write py*.exe to c:\Windows (=> no need to change your PATH) whereas the launcher versions write to C:\Program Files (=> PATH needs to be changed).

Vasudev Ram said...

Cool, thanks for the info, Vinay.

Brett, I guess Vinay answered your question :-)

py.exe is a good tool ...

Pranav said...

Thanks Vinay for this awesome tool.