Content · Programming · Python

Python Windows: Working with the py Launcher

The Windows py command can select a specific Python runtime, making it especially useful when several versions are installed. Learn the essential ideas and try a practical example.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

The Windows py command can select a specific Python runtime, making it especially useful when several versions are installed.

Understanding the Concept


The modern Install Manager accepts py -V:3.15 followed by a script or normal Python options. The shorter py -3.15 form may also work for an official CPython runtime, but the explicit tagged form is clear. Commands such as py list and py install are manager actions, not Python language statements. The older legacy launcher has some similar version-selecting behavior but is not the same tool.

When and Why You Would Use This


You can check version, execute a source file, or run a standard-library module using the same version selector. This avoids changing the computer-wide default interpreter simply to complete one project.

Practical Example


py -V:3.15 --version
py -V:3.15 hello.py
py -V:3.15 -m pip --version

Understanding the Example


The commands check the selected runtime, run hello.py in the current folder, and inspect pip for that runtime. Run the second only after creating hello.py. A missing file produces a file-path error, not an installation error.

Try It Yourself


Create hello.py and run it once with py -V:3.15 hello.py and once from PyCharm. Compare the output.

Common Beginner Mistakes


  • Writing py commands inside Python source files rather than a shell.
  • Confusing py list with Python’s built-in list() constructor.
  • Using unqualified pip and inadvertently installing into another Python version.

Key Takeaways


  • The py launcher can target Python explicitly.
  • Version selection works with scripts and -m modules.
  • Use the matching interpreter when installing project dependencies.
Share this resourceSend this page to someone who may find it useful.