"#!/usr/bin/env python" vs. "#!/usr/bin/python"?
D'Arcy Cain
darcy at druid.net
Fri Sep 28 09:19:54 EDT 2012
On Fri, 28 Sep 2012 06:57:28 -0400
Roy Smith <roy at panix.com> wrote:
> > 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.
Not just flexible but portable. On various systems I have Python
in /usr/bin, /usr/local/bin and /usr/pkg/bin. "#!/usr/bin/env python"
finds it in each case so I only need one version of the script.
--
D'Arcy J.M. Cain <darcy at druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
IM: darcy at Vex.Net
More information about the Python-list
mailing list