Windows opens .py file with C:\Python27\Python.exe despite rebinding Python.File
I followed Python's official FAQ to make .py file executable, i.e. adding .py to $PATHEXT and bind Python.File to "C:\Python27\Python.exe" "%1" %*. The result was fine:
>assoc .py .py=Python.File >ftype Python.File Python.File="C:\Python27\Python.exe" "%1" %*
I recently installed virtualenv and hope to run a django project in a virtual environment called env1. The path to env1 is: "D:\env1". when I entered env1 in cmd, and try to execute django-admin.py directly, an ImportError Exception is thrown. I figured this is because windows invoked my default python interpreter(c:\Python27\python.exe) under which django is not installed. So I tried the following:
ftype Python.File="D:\env1\Scripts\python.exe" "%1" %*
The command executed successfully. However, the behaviour of executing .py file didn't change at all. Either double clicking the file or executing it directly by filename in cmd, c:\python27\python.exe was always invoked, as was shown from Task Manager.
At this point I can only think of that this problem is related to some windows settings and has nothing to do with virtualenv. Please help to get the binding work properly, Thanks!
Another key is overriding the key set by ftype. You can search for the key using Registry Editor also known as regedit. Search for