[issue28686] py.exe ignored PATH when using python3 shebang

Paul Moore report at bugs.python.org
Tue Feb 7 11:19:18 EST 2017


Paul Moore added the comment:

> - when inside a venv (almost always) go 'python' the old way, because 'py' is unreliable here, *unless* you manually check the shebang of your scripts before you execute them. 

No. When inside a venv:

- If you want to use the interactive interpreter, use 'py'.
- If you want to execute a script, use a shebang of #!/usr/bin/env python and then use `py myscript.py`

You should use /usr/bin/python[X[.Y]] shebangs specifically when you want to use the system Python, and bypass venvs. So that's typically for scripts you've installed in your PATH, not for working scripts in your project. You should never use versioned executable names in shebangs with /usr/bin/env.

Your issues seem to come from an insistence on using versioned interpreter names in /usr/bin/env shebangs, which does not work as you expect. (How it actually works is IMO not very helpful, but not easily fixable without shipping versioned executables, which is an entirely different debate which I don't intend to get into here).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28686>
_______________________________________


More information about the Python-bugs-list mailing list