Adam Laiacano

I'm a data engineer at tumblr and this is my blog. I write mostly about personal projects, data science, R/python, and various curiosities.

  1. Setting up python on a fresh OSX install.

    I have seen WAY TOO MANY blog posts about this, but none of them seem to get it right. Python comes pre-installed, but if you use homebrew as a package manager, you should be using the version of python that they provide.

    First up you’ll need to install xcode through the App Store. It’s needed for pretty much all development on OSX for some reason.

    Next up is installing homebrew, which is as easy as running this command:

    ruby -e "$(curl -fsSkL http://raw.github.com/mxcl/homebrew/go)"

    That was easy. Now install the latest version of python 2.7 (currently 2.7.3):

    brew install python

    Now, if you simply run the python command, you’re still going to get the system default version. So we need to fix that. Open up ~/.bash_profile and put these line in there:

    export PATH=/usr/local/Cellar/python/2.7.3/bin:$PATH
    export PATH=/usr/local/share/python:$PATH

    The first one points to the correct version of python. The second one will point to ipython once we install that. Source the ~/.bash_profile file to update the changes.

    source ~/.bash_profile

    Now you should see the following paths if you have the right python and pip setup:

    $ which python
    /usr/local/Cellar/python/2.7.3/bin/python
    $ which pip
    /usr/local/Cellar/python/2.7.3/bin/pip

    Pip is how you’re going to install all of your extra stuff. Let’s install some essentials:

    pip install ipython
    pip install numpy
    pip install matplotlib
    pip install pandas

    I’m also not sure if you need to install gfortran before numpy (I’ve always installed it first as a dependency of R), but if you have to, make sure you do it through homebrew as well: 

    brew install gfortran

    Please let me know in the comments if something fails along the way, but this works well for me.

    Last revised Feb 7, 2013.

  2. 2012-01-09
    #python #osx