Run Python with the py Launcher on Windows

Start Python scripts and switch between installed Python versions using the built-in py.exe launcher.

WindowspythoncmddeveloperLow risk
Run py -3 script.py to run a script with Python 3, and py -0p to list every installed version with its path.

01Command

Command
$ py -3 script.py

02What it does

The official Python installer ships a py.exe launcher in C:\Windows so "py" works in cmd and PowerShell even when python.exe is not on PATH. The version switch saves real pain on machines with multiple Pythons: py -3.11 script.py targets a specific version, and py -0p prints each installed version with its install path. Shebang-style comments at the top of a script (e.g. #! python3) let the launcher pick the interpreter automatically.

03Risk

RiskLow risk
RequirementsPython installed from python.org (the py.exe launcher is included in the installer)
!Warning: If py is not recognized, Python was installed without the launcher option or PATH updates need a new terminal window.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Using Python on Windows
    Python Software Foundation · vendor-doc · 2026-09-17
    Evidence: Documents the py.exe launcher: py -3 runs Python 3, py -0/-0p lists installed versions with paths, and shebang lines select interpreters.

Last verified: 2026-09-18 · Category: Developer

06Related solutions