Installing IPython Notebook for Mac

For my research with Bill Punch, I am looking into ways to integrate the new IPython Notebook (ipynb) in the classroom. This post is strictly dedicated to talking about the best way I have found to install ipynb on a Mac. See my other post about the woes of installing ipynb for a new user.

Okay, so. The installation. I have a Mac running OS X Lion (10.7.4). After trying a bunch of different methods for the install, I have determined that using MacPorts is the quickest and most effective way to get ipynb.


How Python Installs

But first, let’s talk about how Python is installed on your computer. When you download Python from, the install process creates a Python directory here:

$ /Library/Frameworks/Python.framework/Versions

Every version of Python that you install has its own directory here, which contains independent versions of all necessary Python code and packages. For example, on my system I have Python 2.7 and Python 3.2

You can see that both the 2.7 and 3.2 directories contain all necessary files for Python to run on my machine. There is also a “current” directory, which houses the files for whichever version of Python I am running most currently. Whatever is in “current” is what is executed when I call “python” from the command line.

In order to run a specific version of Python, I have to use a Python version-specific command. To see which possible commands you have, type “python” in the command line, then hit Tab:

Now, to run Python 3.2, I must use the command “python2.7.” When I call “python” only, I get the default Python (in my case, 2.7). See below for an example of me calling each version of Python, as well as the current/default version. This means that when I want to run a Python 3 file, I have to call “python3.2” – otherwise I will be trying to run with Python 2.7.

Why is all of this information important? Well, ipynb uses different packages depending on the version of Python you are running. Further, when we use MacPorts next, you will see that the directories where we install Python are changing.


Using MacPorts Instead

MacPorts is a package manager to install open source software on the Mac. It greatly streamlines the installation processes for Mac, which otherwise can be very difficult (as discussed in my complaint post). We are going to use MacPorts to install ipynb, and that means we have to first get MacPorts. Here is the install page. Simply go there and get the appropriate download for your system. It will give you a .pkg file which then walks you through the install step-by-step.


Install Python via MacPorts

Here is where we depart from the traditional Python version install described in the previous section. MacPorts maintains its own directories for open source software, separate from where Python usually installs. That means that when you install Python via MacPorts, your Python files are going here:

$ /opt/local/Library/Frameworks/Python.framework/Versions

As opposed to the than the usual:

$ /Library/Frameworks/Python.framework/Versions

What does this mean for you? Well, even if you already have Python installed on your machine, you *still* have to install the MacPorts version. Luckily, the install process with MacPorts is quick and easy (which is why we want to use it). As a matter of fact, We will install Python as we install the packages necessary for IPython.


 Getting the Packages

This part is where the installation process becomes tricky. IPython Notebook is built on a series of packages, which you must install before you can get ipynb. The order you install them is also important, so make sure to follow these steps in order:

(1) Choose which version of ipynb you want to install. For beginners, I would recommend 2.7, since it is the most stable and is mostly forward- and backward- compatible. All of your installation will depend on which version you choose now. For this tutorial, I am going to assume you are installing 2.7. To get a different version, simple alter the version number in the command.

(2) Get pyzmq. What is it? pyzmq is a Python-based message queue. Note that in order to get pyzmq, you need Python. So, MacPorts will first install the appropriate version of Python for the pyzmq you request. Here is how to install pyzmq:

$ port install py27-zmq

(3) Get tornado. Follow the same process as in step (2) to get tornado. Tornado is an open source web server.

$ port install py27-tornado

(4) Get nose. Nose is an open source package used in testing.

$ port install py27-nose


 The Last Step

Get ipython! After all that work, you are finally ready to install ipy with MacPorts:

$ port install py27-ipython


 Test Your Installation

Let’s just make sure that ipynb actually runs now. To do so, simply execute the following command in the terminal:

$ ipython-2.7 notebook


2 thoughts on “Installing IPython Notebook for Mac

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s