
You can also set PY_PYTHON3 or PY_PYTHON2 to specify default python 3 and python 2 versions (if you have multiple). You can see what version of python is your default by typing py. Set your preferred default version by setting the PY_PYTHON environment variable (e.g. In an Admin cmd terminal, run:įtype Python.File="C:\Windows\py.exe" "%L" %*įtype Python.NoConFile="C:\Windows\pyw.exe" "%L" %* Set the command line file extension association to use the Python Launcher for Windows (this will make typing py optional). Setup your "Open with." explorer default program association with C:\Windows\py.exe If you are a Windows user and you have a version of Python 3.3 or greater, you should have the Python Launcher for Windows installed on your machine, which is the recommended way to use for launching all python scripts (regardless of python version the script requires).Īlways type py instead of python when running a script from the command line. pyo to the PATHEXT environment variable and then the command line can just be script with no extension. Py -0 # list installed Python versions (latest PyLauncher).Īdditionally, add. Py -3.9-32 script.py # select version 3.9 32-bit specifically.

Py -3.6 script.py # select version 3.6 specifically. Py.exe can also be run with switches to force a Python version: py -3 script.py # select latest Python 3.X version to be used. If fact it's best to remove Python directories from the PATH, so "python" won't run anything and enforce using py. The command line for Python.File is the Python Launcher, which is installed in the Windows directory since it is always in the PATH.įor the association to work, run scripts from the command line with script.py, not "python script.py", otherwise python will be run instead of py. py files are associated with the Python.File type. Here's how to check if the launcher is registered correctly from the console: C:\>assoc. The latest version has a py -0 option to list the installed Pythons and indicate the current default. Newer versions of Python update the launcher.

This default can be customized through a py.ini file or PY_PYTHON environment variable.

If it is not specified, the default is to use the latest Python version for the current architecture (x86 or 圆4). This allows many versions of Python to co-exist and allows Python scripts to explicitly specify which version to use, if desired. This program ( py.exe) is associated with the Python file extensions and looks for a "shebang" comment to specify the python version to run. The Python installer installs Python Launcher for Windows.
