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.
[…] For installation instructions on a Mac please refer to this tutorial. […]
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?
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.
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?
I think you should be fine, Anaconda runs itself in pretty tight isolation.
That’s great, thanks for the quick reply.
[…] I found this to work flawlessly on OS X 10.8.3 https://penandpants.com/install-python/ […]
What is “.profile, .bash_profile, or .bashrc”?
The Anaconda installer should now take care of configuring your system, so you won’t need to update your PATH. You can read more about shell initialization files at http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_01.html.
Great Post. Would you have a similar guideline to install python in pc ?
I would recommend installing Anaconda: http://continuum.io/downloads
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?
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.