#!/usr/bin/python or #!/usr/bin/env python?

skip at pobox.com skip at pobox.com
Tue Aug 8 15:41:28 EDT 2006


    John> I understand the difference, but I'm just curious if anyone has
    John> any strong feelings toward using one over the other? 

#!/usr/bin/python -> never

#!/usr/bin/env python -> always

Strong enough?


    John> I was reading that a disadvantage to the more general usage
    John> (i.e. env) is that it finds the first python on the path

That's generally the one you want.  On most systems /usr/bin/python will be
the system-provided one (e.g. the one that came with your Linux
distribution).  You might prefer a Python of more recent vintage though.
That's commonly installed in /usr/local/bin/python and /usr/local/bin is
generally ahead of /usr/bin in PATH.

    John> And is Python found in directories other than /usr/bin often
    John> enough to justify using the more general form?

On my Mac I install most stuff in ~/local simply so I don't need to be
root and don't disturb the system-provided software.  In cases where other
users need to run such tools I generally use /usr/local.

Skip




More information about the Python-list mailing list