#!/usr/bin/env python vs. #!/usr/bin/python

Thorsten Kampe thorsten at thorstenkampe.de
Fri May 2 13:55:04 EDT 2008


* Ben Finney (Sat, 03 May 2008 00:37:45 +1000)
> Thorsten Kampe <thorsten at thorstenkampe.de> writes:
> > * Ben Finney (Fri, 02 May 2008 23:30:01 +1000)
> > > The OP was asking why people prefer on over the other. My answer
> > > is that I prefer specifying "give me the default OS Python"
> > > because anything not installed by the OS is to non-standardised
> > > for me to worry about.
> > > 
> > > Others may prefer something different, but then they get to wear
> > > whatever problems occur as a result of that choice. I continue to
> > > be bemused by that preference, and nothing that I've seen so far
> > > in this thread illuminates the issue more.
> > 
> > You're missing the point. Apart from the really dubious terms you
> > use ("OS installable package"), using env in the first line has
> > exactly the effect to use the default path of Python (which is the
> > first entry in your path)
> 
> No, because it's quite common for the PATH variable to have
> '/usr/local/bin' appear *before* both of '/bin' and '/usr/bin'.
> 
> If the system has a sysadmin-installed '/usr/local/bin/python'
> installed as well as the OS-installed '/usr/bin/python', then the two
> shebang options the OP raised will behave differently on such a
> system. This seems to be quite the point of the discussion.

Again you're missing the point. If you or whoever installs Python (or 
another version of Python) to /usr/local/bin and puts this in the path 
to front (as it's often done) then /you/ want that Python to be the 
"default" one. It would just be silly to say "no, I the developer want 
/usr/bin/python".

So in general "#! env" is better while in certain circumstance 
hardcoding the path to /usr/bin/python can be better.


Thorsten



More information about the Python-list mailing list