3.8. Python Launcher for Windows 27 Python Setup and Usage, Release 3.9.5 You should find that the latest version of Python you have installed is started - it can be exited as normal, and any additional command-line arguments specified will be sent directly to Python. If you have multiple versions of Python installed (e.g., 2.7 and 3.9) you will have noticed that Python 3.9 was started - to launch Python 2.7, try the command: py -2.7 If you want the latest version of Python 2.x you have installed, try the command: py -2 You should find the latest version of Python 2.x starts. If you see the following error, you do not have the launcher installed: 'py' is not recognized as an internal or external command, operable program or batch file. Per-user installations of Python do not add the launcher to PATH unless the option was selected on installation. New in version 3.5. If the launcher is run with no explicit Python version specification, and a virtual environment (created with the standard library venv module or the external virtualenv tool) active, the launcher will run the virtual environment’s interpreter rather than the global one. To run the global interpreter, either deactivate the virtual environment, or explicitly specify the global Python version. Let’s create a test Python script - create a file called$_{hello.py}$ with the following contents From the directory in which hello.py lives, execute the command: py hello.py You should notice the version number of your latest Python 2.x installation is printed. Now try changing the first line to be: #! python3 Re-executing the command should now print the latest Python 3.x information. As with the above command-line examples, you can specify a more explicit version qualifier. Assuming you have Python 2.6 installed, try changing the first line to$_{#! python2.6}$ and you should find the 2.6 version information printed. Note that unlike interactive use, a bare “python” will use the latest version of Python 2.x that you have installed. This is for backward compatibility and for compatibility with Unix, where the command$_{python}$ typically refers to Python 2. #! python import sys sys.stdout.write("hello from Python %s "%(sys.version,)) From a script Virtual environments