473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Executing python scripts

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
Jul 18 '05 #1
2 1933
Shufen <s4******@student.uq.edu.au> wrote:
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
Jul 18 '05 #2
Alex Martelli wrote:
Shufen <s4******@student.uq.edu.au> wrote:

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.


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
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Andrew Chalk | last post by:
Is this possible? In my CGI app. I display a web page with a link (anchor). When the link is clicked I want to exectute a python script rather than go to an HTML page. Many thanks.
8
by: Darren Dale | last post by:
Is there a place to put python programs so I dont have to refer to the absolute path everytime I want to call them? For example: if I am in /home/me and want to execute: python...
13
by: Darren Dale | last post by:
Some time ago I asked about executing a python program or script. For windows, I was informed that the .py extension could be added to some list of executable extensions, and then I could just type...
0
by: Nick Coghlan | last post by:
Anyone playing with the CPython interpreter's new command line switch might have noticed that it only works with top-level modules (i.e. scripts that are directly on sys.path). If the script is...
15
by: Nick Coghlan | last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path. Trying to use it with modules inside packages will fail with a "Module not found" error. This PEP aims to fix that...
1
by: Phil | last post by:
Hi, I have my create statments for tables, procedures, views, etc in individual Transact-SQL script files (.sql). I wnat to write another script file that executes these scripts in the...
1
by: amaltasb | last post by:
I have few modules which are in perl, and all other scripts are in python. Is it possible to execute the perl scripts within python or import them like: Thanks
7
by: RawMustard | last post by:
Hi Folks, my first post here. Sorry to start with a request. I'm having trouble executing python scripts compiled to byte code on ubuntu feisty server version. Basically I can type ./MyScript.py...
6
by: Tim Rau | last post by:
I'm working on a game, and I'd like players to be able to define thier ships with scripts. Naturally, I don't want to give them the entire program as thier romping ground. I would like to invoke a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.