IPython with Python version 2.6 on OS X Leopard

I recently installed the excellent IPython program, a beefed-up Python console that provides a raft of extra features over the default interpreter and makes it even more of a pleasure to work with this language.

When you install IPython on Mac OS X Leopard using the standard method, it only installs against the system’s default version of Python: 2.5.1. However, since I had previously installed Python version 2.6.1 on my system I wanted IPython to work with this newer release.

It was surprisingly difficult to find out how to achieve this, so in case anyone else wishes to do the same here’s the process that worked for me. Download the IPython tarball from the distributions directory (e.g. ipython-0.9.1.tar.gz), extract the archive, change into the extracted directory and run:

sudo python2.6 setup.py install

Notice that the command explicitly invokes the 2.6 version of python with the python2.6 alias: this simple step is enough to properly link your IPython installation with the newer Python. It is obvious in hindsight that this would work, but I wasted enough time pointlessly messing with environment variables and paths that I thought it was worth a blog post.

Don’t try this with the bleeding-edge Python 3K because IPython is not yet compatible with this version, but it seems to work fine with 2.6.1.

This entry was posted in Python, Tips. Bookmark the permalink.

7 Responses to IPython with Python version 2.6 on OS X Leopard

  1. Kevin Lee says:

    Thanks James. I’ve tried all sorts of hacks and could not accomplish this – good to see someone has figured it out. Now my question is: if I already have iPython working on OSX Leopard’s default install of Python, can I just install it again?

    • James Murty says:

      Yes, I just re-installed IPython with the command in the post and it worked out fine. The original IPython will be overwritten though — I’m not sure if there’s a way to have both the Python 2.5 and 2.6 versions installed.

  2. Kevin Lee says:

    strange…I followed the post, and ipython installed just fine into the framework install of python 2.6 (I can see the files being copied into the right place). However, when I run iPython, it shows the interpreter it’s using is good old 2.5 again.

    I could have sworn I had this working before.

    • James Murty says:

      Have you tried re-installing IPython with the 2.6 method?

      Alternately, you could try editing the ipython executable file which is in /usr/local/bin (on my system anyway). This executable is just a python script that runs the IPython interpreter, and it includes the full python version path as the first line. Here is the path at the top of my version:
      #!/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python

  3. diego federici says:

    I tried several solutions to change the python version in ipython without success, but this works perfectly!
    Also, if you need several versions have a look at:
    http://ipython.scipy.org/moin/FAQ#head-c23150d7cc12378683737626b1c7ac4986d3a853

  4. adverick says:

    Hi!
    One simple trick:
    sudo cp /usr/bin/ipython2.5 /usr/bin/ipython2.6
    alias ip6=’/usr/bin/ipython2.6′

    • James Murty says:

      I’m not sure how copying the ipython2.5 binary to a name containing “2.6″ would help?

      In any event, my iPython installation doesn’t include the ipython2.5 script so this wouldn’t have worked for me.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>