Adam Laiacano

I'm a data engineer working here at tumblr, living in Brooklyn, and
Currently listening to: .

2012-01-09 Notes: 24

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.

To first install homebrew, make sure you installed xcode through the App Store, then run this command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"

That was easy. Now install python 2.7.2:

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 lines in there:

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

The first addition to the path is the location of python 2.7.2, and the second is the location of easy_install, which you’re going to need. 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 easy_install setup:

$ which python
/usr/local/Cellar/python/2.7.2/bin/python
$ which easy_install
/usr/local/share/python/easy_install

I’m told that you should use pip instead of easy_install, but you need to use easy_install to install pip.  It’s a bit of a catch-22, but to get pip installed:

sudo easy_install pip

Finally, you can install the rest your python packages like ipython and numpy through pip.

pip install ipython

etc.

Tags: python osx

  1. blogbourse reblogged this from adamlaiacano
  2. macdiva reblogged this from adamlaiacano
  3. adamlaiacano posted this