Getting iPython Notebook to Run “Correctly” in Mac OS X 10.8

I’m going to keep this post brief so that the steps are clear and concise.  The reason for writing this post is that I wanted to get iPython Notebook, a powerful tool for data analysis, to run with plotting and pandas in Mac OS X 10.8.  When I initially tried to get this running, I would encounter errors where there were conflicts between 32-bit and 64-bit installations of different packages.  After a good deal of trial and error, I found the following steps resulted in a full iPython Notebook environment with Pandas and Matplotlib functioning flawlessly.

Steps:

1) Create a virtualenv without site packages: –no-site-packages -p python-32

First things first, start with a clean python virtual environment for this installation.  The secondary bonus is you won’t be messing with your current Python installation.  You should use virtualenv’s whenever possible to avoid conflicts and messing up your Python installation between projects.

2) Fix your PYTHONPATH (If you have stuff gunking it up.)

This should be self explanatory, but if you run into issues with packages not being detected, check your PYTHONPATH to see if there are conflicts being loaded.

3) Ensure that you are in fact in 32-bit Python: python -c “import sys; print(sys.maxsize)”

Matplotlib and Pandas want to work together, and they must do so in 32-bit mode.  If you do this correctly, the number should correlate with 32-bits, not 64 as happens on some systems.

4) Expose only the 32-bit python installation:

I found this Stack Overflow post tremendously helpful.  This is essential to getting the 32-bit installation seen by iPython Notebook for conflict free running. http://stackoverflow.com/questions/6594558/when-i-create-a-virtualenv-python-runs-in-64-bit-even-when-already-set-to-32-bi

5) Getting matplotlib installed can be tricky:

Installing matplotlib was itself somewhat tricky with the different Python versions and such.  the following command got it running fine for me.  Check the provided link as well if you are curious about the process.

sudo PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig pip install matplotlib http://stackoverflow.com/questions/4092994/unable-to-install-matplotlib-on-mac-os-x

Conclusions:

Hopefully this post got your environment up and running.  iPython Notebook is great for performing data analysis and keeping your research/work organized in an easy to follow fashion.  As a bonus, consider creating an alias to change to your notebook directory and launch iPython Notebook.

Good Luck!

Leave a Reply

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

Are you a spammer? *