[Pythonmac-SIG] Python 2.4.1 not replacing earlier versions.

Chris Barker Chris.Barker at noaa.gov
Fri Sep 2 23:52:52 CEST 2005


Just to add my $0.02 for completeness:

People use:

#!/usr/bin/env python

so that the script will work on any system with a python on the PATH, 
whether it's in /usr/bin or /usr/local/bin or wherever else. 
Particularly on Linux systems, python gets installed different places 
depending on whether it's supplied by the distribution or installed 
separately. I personally like this approach.

Some suggest that you put /usr/local/bin on your path ahead of /usr/bin 
so that your shell will find the your user-installed python first. This 
works fine except for a couple things:

1) if the script is run in someone else's shell that hasn't been set up 
that way, it won't work.

2) if there is something else in /usr/local/bin that is the same as a 
counterpart in /usr/bin, you could accidentally cause problems there.

3) What happens when you install python2.5 and have a bunch of scripts 
still relying on 2.4?

My thought is that you want to control what a python script does, NOT 
what your shell does. In this case, what you want is for your script to 
use python2.4, rather than "the python that happens to be first on the 
path", or "the python that happens to be in /usr/local/bin", so what you 
do is put:

#!/usr/bin/env python2.4

At the top. This guarantees that that script will use python2.4, and 
also documents, for all to see, that that's the version of python that 
it's been tested on.

When installing packages, use:

python2.4 setup.py install.

I think the standard installers put a "python2.4" as well as  "python" 
in usr/local/bin. If they don't, they should, and until then, you can 
put in a link yourself:

cd /usr/local/bin
sudo ln python python2.4

(untested)

I really wish specifying the version would become standard practice in 
python development.

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer
                                      		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Pythonmac-SIG mailing list