How to use py.exe launcher for windows
-
py.exe is a tool to run python commands exclusively for Windows OS.
Type py to check if launcher is installed.
If installed, this will display latest python version.
Without py.exe, to execute python commands like creating a new virtual environment, running a module, etc we will be using commands;
python -m venv TestProject
or
python TestModule.py
With py.exe installed we can do these as;
py -m venv TestProject
or
py TestModule.py
-
The real usage of py.exe is to execute a python package under older version of python.
As an example, if we want to setup virtual environment for python 3.9, we can do so using the command;
py -3.9 -m venv TestProjectTo execute commands under older python versions, use as below;
py -3.3Executes code/module in python 3.3 version
py -3Executes in latest 3.x version available in your machine