[Pythonmac-SIG] Upgrading to 2.4.1
Chris.Barker at noaa.gov
Fri Apr 22 18:36:40 CEST 2005
Bob Ippolito wrote:
> On Apr 22, 2005, at 4:38 AM, Yair Benita wrote:
>> If it co-exist how do I control which one is used when simply typing
>> /usr/bin/python at the command line?
> NEVER EVER change anything in /usr (except /usr/local) or /System. DO
> NOT EVER DO THAT. BAD.
I think the OP was not proposing that, but rather was trying to figure
out how to run the different pythons. So to give a little more info:
Apple puts their python (2.3.0) in:
When you install 2.4.* (and any python that isn't supplied by Apple,
hopefully), it will not put it in /usr/bin . It should put it in
/usr/local/bin/python (or maybe /opt/... or /sw/....)
So, after installing python2.4, you'll have two "python" executables,
but they won't be in the same place. This is where PATH comes in.
at the command line. It will give you a colon separated list of paths
that bash looks for executables in. It looks in the order given, so if
you have /usr/local/bin and /usr/bin in your path, and there is a python
in each one, it will find the one in the path that comes first in the
list. Many folks recommend manipulating your PATH as the way to set the
default python. For instance, if you put:
in your .profile file (there are other placed to put it as well, search
the web for suggestions), then bash will find the new version first, and
run that when you type "python".
However, the most common way to specify python in a script is:
This lets the shell figure out where python is, rather than specifying
the exact path. This is nice, and makes your scripts more portable, but
it means that if you manipulate PATH, you'll change what it found, and
old scripts that depend on the old python will stop working (this was an
infamous problem with RedHat Linux a while back, I don't know if they've
Because of this, I don't recommend altering your default python in that
way. I put:
in my .profile, so that the system one is found first. By the way, this
doesn't just affect python, it affects every command line program. I
don't want to accidentally change the default anything.
Want I do instead is specify the version I want at the command line or
in the script:
(or python2.3, of course)
There should be a /usr/local/bin/python2.4 after you install 2.4. If not
the distribution is broken, but you can fix it easily with a link.
This way, after you upgrade, anything you write now can use python2.4,
and anything you wrote before can still use 2.3.
I hope that helped.
You know, this is enough of FAQ, it must be in the Wiki by now. If not,
I guess I should add it (or perhaps the OP could put this in)
Christopher Barker, Ph.D.
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