Personal tools
You are here: Home Programming Learning Python Installing Python on Mac

Installing Python on Mac

by Brent Woodruff last modified Jul 21, 2008 02:21 AM

Detailed instructions on installing Python and some useful programs and packages on Mac OS X.

LAD

If you're here to get LAD installed, you need Python 2.5, wxPython 2.8, Numeric or numpy, and NetworkX.

 

Mac OS X 10.4 and earlier

Mac OS X 10.4 comes with python (even wxPython!), however it is a very old version. If your only interest in Python is command line programming don't worry about upgrading. The Plone unified installer comes with its own version of Python, so again there's no need to upgrade. But, if you wish to run or write wxWidgets graphical programs it is a very good idea to upgrade using provided Mac packages.

wxWidgets, Numeric, and numpy on 10.4 and earlier

Install everything on the Mac packages page, except pick only one version of wxWidgets (2.8). Then grab the docs and demos from the wxPython download page. Specifically, get the version that matches your python version (such as 2.5).

 

Mac OS X 10.5

Mac OS X 10.5 ships with Python 2.5, wxWidgets 2.8, and Numeric/numpy so there is no need for external packages like in 10.4 and earlier. Additionally, installation of the Apple developer tools will provide the wxPython examples:

# Run this in the Terminal
cd /Developer/Examples/wxWidgets/wxPython/demo
python demo.py

Use easy_install (described below) to get other Python packages such as NetworkX.

The Plone unified installer will, as always, provide its own version of Python that will not conflict with the system version, so there are no worries there.

Easy Install

Easy install is a program for automatically downloading Python packages, called eggs. You can paste the commands below in a Terminal to download and create the needed files and directories.

Download and install ez_setup.py then create the file ~/.pydistutils.cfg (that is, /Users/USERNAME/.pydistutils.cfg) with the following contents. This will put everything installed by easy_install in your home directory for easy management (and by management I mean wiping out and starting over usually). The first time you run easy_install to install something, you may get an error saying the directory doesn't exist - just create the directory with mkdir -p and you'll be all set. This works with both upgraded Python 2.5 on older Macs and the system Python 2.5 on Mac OS 10.5.
# Paste this into your Terminal
echo "[install]" > ~/.pydistutils.cfg
echo "install_lib = ~/Library/Python/\$py_version_short/site-packages" >> ~/.pydistutils.cfg
echo "install_scripts = ~/bin" >> ~/.pydistutils.cfg
mkdir -p ~/Library/Python/2.5/site-packages
curl -O http://peak.telecommunity.com/dist/ez_setup.py > ez_setup.py
python ez_setup.py
rm ez_setup.py

NetworkX

NetworkX is a package for network and graph theory research. It is used in my program lad

and can be installed using easy install.

# Run this in the terminal
easy_install networkx

If that option does not appeal to you, there are OS X downloads available from the NetworkX download site.

SPE Integrated Development Environment

Now for the development environment SPE. This comes with wxGlade, an interface builder, and XRCed, an XML/interface file editor, as well as some other useful things. The best way to get SPE is using subversion, and on Mac OS X I recommend getting the version distributed by CollabNet at

http://downloads.open.collab.net/binaries.html

This version has secure HTTP (https) support, which other versions such as the one provided by Fink do not have.

Go somewhere on your hard drive you want to keep the IDE, such as the Applications directory in your home directory. Checkout SPE using the command line client:
svn checkout svn://svn.berlios.de/python/spe/trunk/_spe

Once that's checked out, run SPE by going in the _spe directory (DO NOT EVER RENAME THIS DIRECTORY) and run 'python SPE.py'. You can update to the latest version of SPE now by going into the _spe folder and running an update:
svn update

Wingware-101 IDE

Those looking for a more professional IDE with commercial support and powerful features such as remote debugging might want to look at Wingware. They have a free version called Wingware-101 which is plenty enough for those getting started. Grab it from their website

Plone

Download the unified installer from http://plone.org/products/plone and run the package installer provided. Once installation is complete, start the server by running:

/Applications/Plone-version/Instance/bin/zopectl start

It can also be useful to run the server in the foreground for debugging purposes:

/Applications/Plone-version/Instance/bin/zopectl fg

With the server up and running, open a web browser and go to http://localhost:8080

Other packages you may be interested in

PyOgre (3D rendering): http://www.ogre3d.org/wiki/index.php/PyOgre
PyODE (Physics engine): http://pyode.sourceforge.net/
PyGame (SDL Graphics, sound, control, etc): http://www.pygame.org/
PyOpenGL (low level graphics): http://pyopengl.sourceforge.net/

Document Actions