On 3/25/20, Barry Scott <ba...@barrys-emacs.org> wrote: >> On 25 Mar 2020, at 09:15, Eryk Sun <eryk...@gmail.com> wrote: >> >> That is not consistent with Unix. env is supposed to search PATH for >> the command. However, the launcher does not search PATH for a >> versioned command such as "python3". Instead it uses the highest >> version that's registered for 3.x or 2.x, respectively, or the version >> set by PY_PYTHON3 or PY_PYTHON2 if defined, respectively. > > I think the reasoning is that the whole point of the py.exe is to avoid > having users edit their PATH on Windows. And further the thinking > goes that you do not need the alternatively named python programs.
The py launcher's "env" command searches PATH for anything from "python" to "notepad" -- but not for a versioned Python command such as "python3" or "python2". It always uses a registered installation in this case, which is at the very least problematic when using "#!/usr/bin/env python3" in an active virtual environment. Paul Moore will probably suggest that the script should use "#!/usr/bin/env python" instead, but that will run 2.x in most Unix systems unless a 3.x environment is active. We can assume that such a script requires 3.x and is meant to run flexibly, in or out of an active environment. I'd prefer a consistent implementation of the "env" command that doesn't special case versioned "pythonX[.Y]" commands compared to plain "python". But another option that will at least make virtual-environment users happy would be for "env" to check for an active VIRTUAL_ENV and read its Python version from "pyvenv.cfg". _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/NEO6ZBIIGL2JWVG77SHUKNTWLY2ZFJ5G/ Code of Conduct: http://python.org/psf/codeofconduct/