"#!/usr/bin/env python" vs. "#!/usr/bin/python"?
Roy Smith
roy at panix.com
Fri Sep 28 06:57:28 EDT 2012
In article <34va6856ocuas7jpueujscf3kdt7k44mfl at 4ax.com>,
Gilles <nospam at nospam.com> wrote:
> Hello
>
> I've seen both shebang lines to run a Python script on a *nix host:
>
> #!/usr/bin/env python
> #!/usr/bin/python
>
> What's the difference?
The first one looks through your PATH to find the right python
interpreter to run. The second one is hard-wired to run /usr/bin/python.
If you only have a single copy of python installed, it doesn't really
matter which you use. But, you might as well get into the habit of
using the /usr/bin/env flavor because it's more flexible.
I'm working on a number of different python projects. For each one, I
set up a new virtual environment using virtualenv. This lets me run
different versions of python in different projects, with different
collections of installed packages (and possibly different versions). I
can only do this because I use the /usr/bin/env line in all my scripts.
More information about the Python-list
mailing list