views:

1943

answers:

3

I have been enjoying learning the basics of python, but before I started reading things I tried to install various python versions and modules clumsily. Now that I have some ideas of what I want to do and how to do it I'm finding that various aspects are broken. For instance, 2.6 IDLE won't launch, and when I try to import modules they usually don't work.

My question is, how would you recommend I clean this up and start fresh? I have read information about modifying the 2.6 install, but I still can't get it to work.

IDLE 2.4 works, and when I launch python from the terminal I am running python 2.4.4.

+4  A: 

I had this problem so much when I first got my Mac. The best solution I found was to delete everything I'd installed and just go with the pythonmac.org version of Python (2.6). I then installed setuptools from the same site, and then used easy_install to install every other package.

Oh, and I got the GNU C Compiler from the Xcode developer tools CD (which you can download from Apple's website), so that I can compile C extensions.

zvoase
dbr has further input on cleaning up the .profile (your environment's PATH and MANPATH variables).
Nerdling
+1  A: 

Macports should be easy to get rid of; just delete /opt/local/. I think that Fink does something similar.

You can do which python to see what python is the default one. The system python should be in /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python

The MacPython you may have downloaded would either be in /Library/Frameworks/Python.framework. You can delete this as well.

Also, both MacPython and MacPorts edit your ~/.profile and change the PYTHONPATH, make sure to edit it and remove the extra paths there.

orestis
+1  A: 

The easiest way to start afresh with Mac Ports or Fink is to simply remove the folder /sw/ (for fink) or /opt/ for MacPorts.

To completely remove them, you will have to remove a line in your ~/.profile file:

For fink:

test -r /sw/bin/init.sh && . /sw/bin/init.sh

..and for MacPorts, I don't have it installed currently, but there will be something along the lines of:

export PATH=$PATH:/opt/local/bin
export PATH=$PATH:/opt/local/sbin


As for installing Python, currently the cleanest way is to build it from source..

I wrote up how I installed Python 2.6 on Leopard here. It was for one of the 2.6 beta releases, so change the curl -O line to the newest release!

In short, download and extract the latest python 2.6 source tarball, then (in a terminal) cd to where you extracted the tarball, and run the following commands..

./configure --prefix=/usr/local/python2.6
make
sudo make install

That will install python2.6 into /usr/local/python2.6/ (the last line requires sudo, so will ask you for your password)

Finally add /usr/local/python2.6 to $PATH, by adding the following line you the file ~/.profile

export PATH=$PATH:/usr/local/python2.6

Then you will be able to run the python2.6 command.

Ideally you would just install MacPython, but it doesn't seem to have a decent Python 2.6 installer yet.

dbr