Why Ubuntu doesn’t support certain form of shebang for Python?
Scott Kitterman
ubuntu at kitterman.com
Tue Nov 11 18:35:09 UTC 2014
On Tuesday, November 11, 2014 13:04:38 Rodney Dawes wrote:
> On Tue, 2014-11-11 at 18:02 +0100, GatoLoko wrote:
> > Since different distributions and unix systems may have different paths,
> > you may want to use the env utility in a shebang like "#!/usr/bin/env
> > python2".
>
> Using /usr/bin/env will cause problems in certain conditions, such as
> when running under a virtualenv and other such environments.
>
> Also, for python 2.x scripts, you should always use /usr/bin/python, and
> if python3 is required, /usr/bin/python3. There is no guarantee that
> "python2" will be a valid command.
The problem is that one Linux distro went insane and pointed /usr/bin/python
at a python3 version, which is the only reason the PEP creating
/usr/bin/python2 exists, so thanks to them there is no common shebang one can
be sure will always work. /usr/bin/python works fine everywhere but one
distro, so that's what I'd use too. /usr/bin/env python{2} is fine for
developer oriented packages where they may want to override the default python
version in some contained environment, but risky for things that are part of
an actual system.
Scott K
More information about the Ubuntu-devel-discuss
mailing list