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

Steven Bethard steven.bethard at gmail.com
Tue Aug 8 15:24:04 EDT 2006


John Salerno wrote:
> I understand the difference, but I'm just curious if anyone has any 
> strong feelings toward using one over the other? I was reading that a 
> disadvantage to the more general usage (i.e. env) is that it finds the 
> first python on the path, and that might not be the proper one to use.

I don't see how that's any different from when the Python at 
/usr/bin/python isn't the right one to use. I know that's true at my 
university:

$ /usr/bin/python -V
Python 2.2.3
$ /usr/local/python/bin/python -V
Python 2.4.3

With this setup, the one in /usr/bin is for the OS and is seldom 
updated, and the one in /usr/local is for users and is updated frequently.

Sure, if someone doesn't put /usr/local/python/bin on their PATH, 
they're not going to get the right Python, but I don't write code to 
Python 2.2 anymore, so if I use ``#!/usr/bin/python`` my code will 
probably just fail.

Obviously, in my own code, I only use ``#!/usr/bin/env python``.

STeVe



More information about the Python-list mailing list