Most common #! format

Peter Funk pf at
Thu Mar 2 15:15:48 CET 2000


Chuck Esterbrook:
> What's the most common #! format?
> #!python
> #!/usr/local/bin/python
> #!/usr/bin/env python

Since MacOS and Windows don't care about this very first line,
this is only interesting to increase portability on unixoid platforms.  

On all flavours of Unix I've ever seen in the last 20 years the utility
'env' used to live in /usr/bin.  This habit seems to be even older than
the invention of the '#!' exec hack (But this is from memory).

So using '#!/usr/bin/env python' as first line is best available solution 
for portable Python programs today.  But:

Today unix like systems can be divided in two major groups:
  - freely available (FreeBSD, NetBSD, Linux, where the several flavours
    of Linux are the most prominent ones)
  - commercial Unices (AIX, HP-Ux, Sun Solaris, SGI IRIX, Unixware)
Today the freely available Unices have about 90% market share (This is 
hard to estimate, since you may copy them over and over without having 
to buy new licenses) and the commercial Unices are slowly dying out 
one after the other.  Most Linux distributions come with a bunch of
useful open source software and so include a ready to run Python system,
where the Python interpreter can usually be found as /usr/bin/python.

However those commercial Unices have some niches, where professionals
may still earn some Money. ;-)  Unfortunately these systems usually
come with the original Unix utilities, which many professionals
(including me) consider simply as broken.  So if you want to make
e.g. a Solaris system usable for many practical tasks you normally end up
first installing gcc, bash, GNU-find and so on and not to forget Python
under /usr/local/bin.  After that you usally extend the default search
path $PATH to also include /usr/local/bin.

However there may be people out there, who are permitted to install
Python under /usr/local/bin but are *NOT* permitted to change the
default search path to include /usr/local/python (e.g. for some
mysterious security policy).  Under this rare circumstances the second
form '#!/usr/local/bin/python' comes into play.  This would allow
to call for example a CGI-script from a web server process, which 
didn't has Python on its search path.  But this situation should 
be considered as very exotic and rare today.

Regards, Peter
Peter Funk, Oldenburger Str.86, 27777 Ganderkesee, Tel: 04222 9502 70, Fax: -60
The way to do research is to attack the facts at the point of greatest
astonishment.                                                    -- Celia Green

More information about the Python-list mailing list