Install Python

My posts on installing Python on Mac OS X seem to be the most popular things I’ve posted so I thought I should gather them in one place. Here are some of your options (by no means all of them), listed from most basic to most advanced.

All-in-One

There are multiple packaged installers for scientific Python including EPD Free from Enthought and Anaconda from Continuum Analytics. Of those two I prefer the Anaconda installation because it contains more packages and because it installs into a single directory in your home folder.

To get started download and run the Mac OS X installer from continuum.io/downloads.html. The installer will automatically configure your system to use the Anaconda Python.

Open a new terminal once that’s complete. Typing which python should show the one in anaconda/bin. If you need additional Python packages not included with Anaconda they can probably be installed using pip, which comes with Anaconda.

From Source

I expect Anaconda should meet the needs of most people. I’d recommend going the route of compiling everything from source only if you expect to need to install things like development versions of software, especially using virtualenv (and virtualenvwrapper, of course).

See my post Install Scientific Python on Mac OS X for instructions on installing Python and the scientific Python stack from source. This is how I install Python on my Mac.

13 thoughts on “Install Python

  1. David says:

    Thanks for your instructions on this. I’m trying to start with the Natural Language Processing with Python book and kept getting an error that matprolib wasn’t installed even though I had installed it multiple times alongside my other Python installation.

    I’m no longer getting the error that matlibpro is missing, but the example I’m trying to run from chap 1 of the book (.dispersion_plot) still isn’t working. Now instead of an error I just get a blinking cursor with no prompt or anything, and no plot. All the other NLTK methods I’ve tried to use worked fine.

    Any ideas?

    1. One key thing is making sure you’re running the correct Python, e.g. the one that has matplotlib installed. matplotlib can also be a big finicky on its own (it has a lot of settings and peculiarities), so if you continue having trouble you might try the matplotlib users mailing list for help.

  2. lewis says:

    I have previously installed Enthought on my MacBook and am now thinking of switching over to Anaconda because of available tutorials. Can you think of any possible conflicts — especially since many of the packages will already be installed?

  3. I’ve installed Anaconda via the pkg installer, but when I run python and attempt to import “from matplotlib import pyplot as plt” , I get the following:

    RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends.

    Not really sure what that means. Have you had this problem?

    1. That probably means that the Python you’re trying to run is not the Anaconda Python. Running type python will let you know which Python is first on your PATH. Make sure the Anaconda Python is the first one on your PATH.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.