[issue38999] Python launcher on Windows does not detect active venv

Eryk Sun report at bugs.python.org
Thu Dec 12 18:19:35 EST 2019


Eryk Sun <eryksun at gmail.com> added the comment:

> I think supporting the shebang line in py.exe is a misfeature and 
> would prefer we'd never done it (though it predates my involvement). 

Do you mean all shebangs, including those with a native file path?
Or do you mean just virtual shebangs, and in particular those that search PATH via "/usr/bin/env"? It's not without controversy even in Unix. For example, see [1] and the rebuttal to it in the comments.

In the case of this issue, "env" is used to run a script in an active virtual environment. This doesn't rely on the user or system PATH, assuming the command can be found in the active scripts directory.

As an alternative to modifying the launcher, pip (via distlib) could be updated to transform "#!/usr/bin/env pythonX[.Y]" shebangs into "#!/usr/bin/env python" when installing scripts in Windows. pip and distlib are third-party tools, however, so that suggestion is beyond the scope of this issue tracker.

[1] https://jmmv.dev/2016/09/env-considered-harmful.html

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38999>
_______________________________________


More information about the Python-bugs-list mailing list