Search code examples
pythonwindowsvirtualenvfile-associationshebang

Why doesn't virtualenv on Windows associate .py/.pyw/.pyo/.pyc files with virtualenv's version of Python executables?


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 Windows taking into consideration that there's no mechanism like shebang on Windows.


Solution

  • File type associations are handled in the Windows registry. The virtualenv activate script would have to modify the registry keys and the deactivate script would need to restore the previous value (or risk breaking the associations).

    What happens if you activate a virtualenv, open a second instance of cmd.exe, and activate a different virtualenv? Unless you deactivate them in the right order, the stored values for the registry keys would be lost.

    I'm not a virtualenv developer, I'd say that the potential problems far outweigh the slight benefit.