- 1 year ago
Specify minimum python version with py.exe (python launcher for windows)
To specify the minimum Python version with py.exe
, the Python Launcher for Windows, you can use the --list
option to display the available Python installations along with their versions and then use the appropriate version specifier in the command.
Here's how you can do it:
Open the Command Prompt or PowerShell in Windows.
Run the following command to list the available Python installations:
shellpy.exe --list
This will display a list of installed Python versions along with their respective paths.
Identify the minimum Python version you want to use and make a note of its version number or name.
Run your Python script using
py.exe
and specify the desired Python version using the appropriate version specifier. For example, if you want to specify Python 3.8 as the minimum version, you can use the>=3.8
version specifier like this:shellpy.exe --version ">=3.8" your_script.py
Replace
your_script.py
with the path to your Python script.
By specifying the desired minimum Python version with py.exe
, the launcher will attempt to run your script with the specified version or a higher version if available. If the minimum version is not installed, it will display an error message.
Note that the version specifier syntax can vary depending on your specific requirements. You can use various operators such as ==
, >=
, <=
, etc., along with the version number or name to define the desired range of Python versions.
Additionally, make sure you have the latest version of py.exe
installed to ensure compatibility with the version specifier syntax.