[Pythonmac-SIG] Guide to installing Unix-Python on MacOS X

Bob Savage bobsavage@mac.com
Wed, 16 May 2001 22:19:13 -0700


Guide to installing Unix-Python on MacOS X

It took me a while to figure out precisely how to install the Unix Python
distribution under MacOSX. I screwed up just about everything there was to
screw up, so I know what a pain it is trying to do this when you don't know
how. I figured there must be at least one person who knows as little as I
did before starting on this journey and they might search the archives of
this group with the hope that they can find a step-by-step no assumptions
made about knowing how to work with a CLI guide to doing such an install, so
I typed up what worked for me. If anyone sees something that is wrong,
please write in to the list so that people will see your correction, and not
just the bone-headed thing I wrote.

Here is what I did step by step:

[1] get the most recent release from http://www.python.org
at the time of this writing that was Python 2.1

[2] if it isn't already uncompressed, uncompress it now, you can do this by
dropping it on Stuffit Expander even though it has a ".tgz" or ".tar.gzip"
ending.

[3] open the Terminal application (you should find it in the Utilities
subfolder of the Applications folder). In case you don't know, in Unix-speak
that would be described as Applications/Utilities. You'll see a lot of stuff
like that n just a minute.

[4] start typing stuff. When I show you stuff to type into the Terminal
application, I will show it as being typed like this:

%ls

That means type 'ls' and enter. I don't know what precisely your command
prompt (the thing I am representing as '%' is going to look like. Mine looks
like this: "[localhost:~] bsavage% ".

[5] type this:

%setenv OPT '-g -traditional-cpp'

[6] now you need to change directories to the one that was created by
uncompressing the Python distribution. An easy way to do this is to type 'cd
' at the prompt **WITHOUT hitting enter** and then dragging the folder into
the Terminal window. Then hit enter. On my system it looked like this:

[localhost:~] bsavage% cd /Users/bsavage/Desktop/Python-2.1

[7] type this into the Terminal and watch as lots of stuff that you don't
understand goes by

%./configure --with-suffix=.exe --with-dyld

[8] when you get a command prompt again enter this, and watch some more
mystifying messages for a while

%make

** NOTE: for me, this resulted in about six errors similar to this (if this
is a problem, hopefully someone will speak up):

In file included from /usr/include/unistd.h:72,
                 from Objects/fileobject.c:12:
/usr/include/sys/unistd.h:87: warning: `_POSIX_THREADS' redefined
config.h:159: warning: this is the location of the previous definition

[9] now we use the newly built copy of Python to help us :) -- to do this we
are going to ask for root permission, so you will be asked for a password.
This is the "root" password, which is probably the password that was first
supplied when the computer was installed, meaning the password for the first
user created, but it stayed the same if that first user changed their
password since that time.

%sudo ./python.exe setup.py install

[10] copy the executable into the right place (and lose the unfashionable
".exe"):

%sudo mv python.exe /usr/local/bin/

[11] copy the standard modules into place:

%sudo mv Lib /usr/local/lib/python2.1

[12] now we change the owner to root, and the group to wheel:

%sudo chown -R root /usr/local/lib/python2.1
%sudo chgrp -R wheel /usr/local/lib/python2.1/Lib/

[13] now we have to setup a couple of things in your environment. You need a
folder called tcsh inside another folder called init. You can do this on the
command line like this (note: this should warn you before overwriting the
directory, but don't blame me if your system is configured to let you trash
things and you do it by typing in something on the command line that someone
who admits willingly to being fairly ignorant in these matters said to
type):

%mkdir ~/Library/init/tcsh

[14] No you are going to create a file so Python can find what it needs to
run. AGAIN I am assuming here that you do not have a file called rc.mine
already. If you do, you can just edit it and save yourself some grief by not
overwriting this VERY IMPORTANT file. If you want to create the file via the
command line anyways, type:

cat > ~/Library/init/tcsh/rc.mine

[15] you should have a blank line staring back at you, either in Terminal,
or in TextEdit or something similar. Type the following lines, they should
probably be typed as two continuous lines, each starting with "setenv", but
maybe it is okay if it splits, I honestly don't know.

setenv PYTHONPATH 
/usr/local/lib/python2.1/Lib/:/usr/local/lib/python2.1/site-packages/
setenv PYTHONHOME 
/usr/local/lib/python2.1/Lib/:/usr/local/lib/python2.1/site-packages/

[16] if you are typing this into the terminal, you need to type "control-D"
at an empty line.

[17] quit out of the Terminal application and start it again (this forces
the file you just created to get loaded). Now you should be able to type the
following and get the Python interactive interpreter to run!

%python

>From here on out it should be just like in the Unix-centric documentation
that you see all over the place. Happy python-ing!

Bob Savage