Python 2 and Python 3 on Windows 10

I use Python 2.7 but to add plugins to Plover (steno program) I need Python 3. My options are to have both Python versions on Windows 10, or to convert my Python scripts to do the same when run by Python 3 as they do when run by Python 2. Is there official advice for doing either of these things? Or would it be better to use separate machines? My scripts work mainly with text input and output, but one interfaces with a proprietary program via an ActiveX DLL.

It’s 2022. Convert your scripts to Python 3. But in the meantime, there should be no problems having two Pythons on your computer; I have ten different versions of CPython, plus PyPy2 and PyPy3, Jython, MicroPython, and probably a few others I’ve forgotten. Python coexists with itself well.

I assume that converting from Python 2 to Python 3 would affect apps that have their own Python scripts written by the authors. How do they select which Python to use, if there are more than one Python in the system?

On Windows, commonly an installed application would use a private Python interpreter, probably based on the embedded distribution.

For development and general scripting, a console launcher named “py.exe” is associated with “.py” and “.pyz” (zipapp) files. There’s also a GUI launcher named “pyw.exe” that’s associated with “.pyw” and “.pyzw” files. The launchers support a Unix-like shebang on the first line of script. The shebang can be either a native Windows path, such as #!"C:\Program Files\Python311\python.exe", or one of a small set of virtual Unix commands, such as #!/usr/bin/python3 and #!/usr/bin/env python3.

Instead of adding a particular Python installation to PATH, it’s popular to just use the py launcher, which supports running any registered installation. For example, the command line py -3.10 "path\to\" <arguments> will spawn "path\to\Python310\python.exe" "path\to\" <arguments>. A job couples the “py.exe” and “python.exe” processes, such that terminating the launcher also terminates the interpreter.

For installed packages, pip embeds each entrypoint script in a launcher, such as “script.exe”. For example, running "path\to\Scripts\script.exe" <arguments> will spawn "path\to\python.exe" "path\to\Scripts\script.exe" <arguments>. A job couples the “script.exe” and “python.exe” processes. In a virtual environment, “python.exe” itself is usually a launcher (if symlinks aren’t used), in which case running the script creates three processes and two jobs, e.g. script.exe → {python.exe → {python.exe}}.

Many thanks for this explanation.