Why Ubuntu doesn’t support certain form of shebang for Python?

Barry Warsaw barry at python.org
Tue Nov 11 18:31:09 UTC 2014


On Nov 11, 2014, at 01:04 PM, Rodney Dawes wrote:

>Using /usr/bin/env will cause problems in certain conditions, such as
>when running under a virtualenv and other such environments.

The general recommendation is that /usr/bin/env is a good shebang to use when
your package is under development, but once deployed (e.g. installed in
/usr/bin as part of a .deb), it should use an explicit path to a Python
interpreter.  That means /usr/bin/python for Python 2 and /usr/bin/python3 for
Python 3.

If you're using the Python helpers to build your distutils/setuptools-based
packages, it should Just Work.

>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.

Certainly true for the widest cross platform support, however on Debian and
Ubuntu /usr/bin/python2 does point to the latest Python 2 release
(e.g. python2.7).

Cheers,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-devel-discuss/attachments/20141111/8dba7bf7/attachment.sig>


More information about the Ubuntu-devel-discuss mailing list