[Tutor] "#!/usr/bin/env python" vs "#!/usr/local/bin/python"
wescpy at gmail.com
Thu Jun 14 20:13:07 CEST 2007
> Okay, I guess, people are missing points here.
> You are specifying the location to the python executable in your machine,
> that rest of the script needs to be interpreted with.
> You are pointing to python is located at /usr/local/bin/python
> Consider the possiblities that in a different machine, python may be
> installed at /usr/bin/python or /bin/python in those cases, the above #!
> will fail.
> For those cases, we get to call the env executable with argument which will
> determine the arguments path by searching in the $PATH and use it correctly.
> #/usr/bin/env python
> Will figure out the correct location of python ( /usr/bin/python or
> /bin/python from $PATH) and make that as the interpreter for rest of the
> - ( env is almost always located in /usr/bin/ so one need not worry what is
> env is not present at /usr/bin)
senthil is correct in this regard. the bottom line is that the one
with env is more flexible and will run on more systems and more types
of systems because it uses the "env" command to find where python is
located and executes it.
the other one simply will *not* work if python is not installed in
that exact location.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
More information about the Tutor