[Pythonmac-SIG] Interactive shell

Chris Barker Chris.Barker at noaa.gov
Tue Nov 22 18:19:37 CET 2005


Abe Mathews wrote:
> You need to create a link in /usr/bin to python2.4.

Sorry Abe, but:

DON'T DO THAT

There are standard ways to do things that will prevent you from messing 
up your system.

Rule of thumb: don't mess with anything in /usr or /system. That's 
Apple's job.

When you add things, if they are are "unixy" then you'll put them in 
/usr/local (that's what "local" means, more of less).

So, the Python you installed probably already put python and python2.4 
in /usr/local/bin. What you need to do is put /usr/local/bin on your 
path. There are are a lot docs on the web about how to do this, and more 
than one way, but I think the most common is to create a file called 
.profile, and put it in your home directory. Put in this line:

export PATH=$PATH:/usr/local/bin

If .profile already existed, then just add this line to it

restart terminal, and, to see if you did it right, type:

echo $PATH

And you should get a colon separated list of directories in which the 
shell will look for executables.

Now when you type:

python

on the command line, you'll get the old, Apple supplied python.

when you type:

python2.4

you'll get the new one.

In addition, I like to put:

#!/usr/bin/env python2.4

at the top of scripts to make sure I get the right python.

If you are quite sure that you want your own stuff to take precedence of 
system stuff, you can change that line to:

export PATH=/usr/local/bin:$PATH

That will put /usr/local/bin in the front of the search path, so the 
shell will find the python in there before the system one. IN this case,

python

will get you 2.4, and to get the old one, you'll need to type:

python2.3

or

/usr/bin/python

(by the way, this has been discussed ad nausium on this list in the past)

-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