Setting Up Python on OSX Mountain Lion (Updated at May 21, 2013)

Setting up programming environment is frustrating for newcomers. Although it is much easier than it was before, it’s still worth it to take note.

2. Homebrew

Next, install OSX most popular package manager homebrew. Just copy and paste this command in the terminal.

If it shows an error about user permission, do the following

and setup environment variables in ~/.bash_profile (if the file does not exist, create one)

Now you can install the followings with homebrew.

Years before Mountain Lion, I used to install fortran via High Performance Computing for Mac OSX, but it doesn’t work well with homebrew. Now it’s best to install everything with homebrew.

3. Python Virtualenv

Now, if you type which pip it should print /Users/YOUR_HOME/.virtualenvs/data-scientists/bin/pip.

Install scipy, numpy, ipython, and matplot.

Finally, install opencv

If you want a additional nice GUI application for ipython, you can download it from IPython Notebook.

Trouble shooting

Sometimes homebrew has trouble with fetching the source code. If you found it is stuck on downloading the files, do the following

It will show the URL of the file it is going to download. Stop the command with ctrl-c, paste the URL to your browser and download it. After the download is complete, move the file to /Library/Cache/Homebrew.

Continue the installation by