The official solution for coexistence seems to be the Python Launcher for Windows, PEP 397 which was included in Python 3.3.0. Installing the release dumps py.exe
and pyw.exe
launchers into %SYSTEMROOT%
(C:Windows
) which is then associated with py
and pyw
scripts, respectively.
In order to use the new launcher (without manually setting up your own associations to it), leave the "Register Extensions" option enabled. I'm not quite sure why, but on my machine it left Py 2.7 as the "default" (of the launcher).
Running scripts by calling them directly from the command line will route them through the launcher and parse the shebang (if it exists). You can also explicitly call the launcher and use switches: py -3 mypy2script.py
.
All manner of shebangs seem to work
#!C:Python33python.exe
#!python3
#!/usr/bin/env python3
as well as wanton abuses
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…