What is the reason virtualenv does not associate .py(w) files with virtualenv\'s version of Python executables? This seems like an ideal task for virtualenv on
.py(w)
The Python launcher supports custom commands. Create a py.ini file in $env:LOCALAPPDATA with a section like this:
[commands] venvpython=C:\Path\To\Virtualenv\Scripts\python.exe
Now, you can use venvpython in the #! line of your script:
#!venvpython import sys print(sys.executable)