How to install Python pandas Development Version on Mac OS X

The pandas data analysis module is quickly becoming the go-to tool for data analysis in Python. Certain features, such as in memory joins and sorts, become extremely powerful when dealing with in-memory datasets. Often times, operations that take hours in Excel to execute take only seconds using pandas.

As the recent re-covert to Mac OS X, I wanted to get setup with the development version of pandas on my new machine running Mac OS X 10.8.

To begin, we need to have a few things installed, particularly pip and homebrew.

If you have not yet installed pip, and have a valid Python installation on your machine, simply run sudo easy_install pip in your terminal.

Once that’s done, we need to install a few libraries before trying to install our Python libraries.

This will bring in all the compilers and libraries that we’re going to need to build our stuff later on.

Assuming that you want the following libraries installed at the global Python install level, rather than a virtual environment, you can install the requirements to build pandas in a single line.

With that, you should be able to clone the latest pandas repository and install the latest development version.

That’s pretty much it, if you have any problems, feel free to leave a comment.

  • qwery01

    do you know why I’m getting this error when I run “$ sudo pip install cython”?
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c /private/tmp/pip_build_root/cython/Cython/Plex/Scanners.c -o build/temp.macosx-10.9-intel-2.7/private/tmp/pip_build_root/cython/Cython/Plex/Scanners.o

    clang: error: unknown argument: ‘-mno-fused-madd’ [-Wunused-command-line-argument-hard-error-in-future]

    • h6o6

      This looks like it’s from Cython targeting gcc rather than clang, however this usually is just a warning and does not result in a total halt of the build.

      Can you confirm that you installed gcc (brew install gcc)?

      You can try forcing it with something like…

      env CC=/usr/bin/gcc sudo pip install cython

      Good luck!

      • qwery01

        I’m new to this, so I might not install the gcc properly.
        When I execute “brew instal gcc” It asks me to run “brew tap homebrew/versions”.
        I can’t recall the whole output but basically it says nothing about gcc.. So I randomly go with “brew install gcc48”. will that be the problem? how can i fix this?

        • h6o6

          Aha, I’ll have to update the post. Thanks for pointing this out. When I first wrote this one, homebrew did not version gcc like this.

          Anyhow, I would go with gcc47 but I don’t see gcc48 being a problem, either. Try it out!

          • qwery01

            I’ve tried installed both gcc47 and gcc48 properly but I still got a same error. Any clue?

          • h6o6

            Getting Cython to compile on Mavericks is kinda tricky and there could a be a lot of things going on…

            Make sure your XCode tools are up-to-date, that brew doctor returns no errors, that gcc is properly symlinked to the Cellar, that your environment variables are appropriate in your terminal configuration, etc.

            I would suggest looking around for how to install Cython on Mavericks, as that is kind of outside of the scope of this post :) Good luck!