Setting up Python on my Macbook Pro

I bought a MacBook Pro a couple of months ago (having always worked on Windows) and have started to learn Python.  The first step was to install Python but OSX 10.5.7 actually comes with Python 2.5 pre-installed.  This was handy to get up and running, allowing me to type Python code in the terminal straight away and helping me check that I installed Pydev correctly but I decided to take this advice and upgrade to a newer version.

I opted for ActiveState's Python distribution 2.6.2.2.  I'm really liking the modular nature of Python and using easy_install and pip.  A problem arose, however, when it came to targeting my second Python installation.  The easy_install exe program will target the default installation since it is defined on the System PATH variable.  ActiveState sets up a symbolic link for Python in /usr/local/bin and you can make ActivePython first on your PATH in the terminal window by entering the following:

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

Now when I start Python in the terminal it will be version 2.6.2.2 (i.e., my second installation).  By exiting Python (ctrl+d), I can then add packages (such as numpy) that target this version using either easy_install or pip commands:

easy_install numpy

If I wanted to install a package that I downloaded that has a '.pkg' file extension I found that it also targeted the default Python install for the same reason.  My solution was to also install the package from the terminal by doing the following:

PATH=/usr/local/bin:$PATH; export PATH
cd /Volumes/wxPython2.8-osx-unicode-2.8.10.1-universal-py2.6/
sudo installer -pkg wxPython2.8-osx-unicode-2.8.10.1-universal-py2.6.pkg -target "/"

This is pretty standard stuff but I thought I'd share since it took me a little while to figure out :)

Tags: , ,

This entry was posted on Sunday, September 20th, 2009 at 10:29 pm and is filed under open source, python. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

 

3 Responses to “Setting up Python on my Macbook Pro”

  1. Twitter Trackbacks for fboyle.com » Blog Archive » Setting up Python on my Macbook Pro [fboyle.com] on Topsy.com Says:

    […] fboyle.com » Blog Archive » Setting up Python on my Macbook Pro fboyle.com/blog/?p=31 – view page – cached I bought a MacBook Pro a couple of months ago (having always worked on Windows) and have started to learn Python. The first step was to install Python but OSX 10.5.7 actually comes with Python 2.5 pre-installed. This was handy to get up and running, allowing me to type Python code in the terminal straight away and helping me check that I installed Pydev correctly but I decided to take this advice and upgrade to a newer version. — From the page […]

  2. fboyle.com » Blog Archive » Setting up Python on my Macbook Pro | The Macbook Blog Says:

    […] …Read More […]

  3. Where can I get cool games and widgets for my dashboard on my macbook? | Widget Games Says:

    […] fboyle.com » Blog Archive » Setting up Python on my Macbook Pro document.write(”); Share and Enjoy: […]

Leave a Reply

You must be logged in to post a comment.