Executing python scripts

S

Shufen

Hi,

Can someone please advice me on the differences between this:
#!/usr/bin/env python and these: #!/usr/local/bin/python or
#!/usr/bin/python?

I know the first one locates the Python interpreter according to my
system searching path setting. But I read about an article that
mentioned that if we are running the scripts as a CGI from a Web
server then we should use the latter one. Because I'm using python
scripts as a CGI now and I'm currently using #!/usr/bin/env python
this and it seems fine to me, so I would like to know if there is any
difference.

Thank you for any help.



Shufen
 
A

Alex Martelli

Shufen said:
Hi,

Can someone please advice me on the differences between this:
#!/usr/bin/env python and these: #!/usr/local/bin/python or
#!/usr/bin/python?

I know the first one locates the Python interpreter according to my
system searching path setting. But I read about an article that

Right. The other two hardwire the location. The first will not work on
an installation which only has Python in /usr/bin, and viceversa.
mentioned that if we are running the scripts as a CGI from a Web
server then we should use the latter one. Because I'm using python
scripts as a CGI now and I'm currently using #!/usr/bin/env python
this and it seems fine to me, so I would like to know if there is any
difference.

As long as you control your PATH, and what gets installed where in
directories along your PATH, you should be fine.


Alex
 
P

Peter Hansen

Alex said:
Right. The other two hardwire the location. The first will not work on
an installation which only has Python in /usr/bin, and viceversa.

To clarify (since I misunderstood this when I first read it): Alex
means "the first of the these", referring to the two that don't
look in the search path, when he writes "the first" (and not the
previously referenced "first one" as it seems, at first :).

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top