The easiest way to get matplotlib on the Mac OS X is to use prepackaged python distributions such as Enthought Python Distribution (EPD). Just go to the EPD site, and download and install the latest stable version for your OS.
In case you are not satisfied with EPD or cannot use it for other reasons such as the versions distributed with it, there is a manual (read: harder) way of installing Python, matplotlib, and its dependencies.
We will use the Homebrew (you could also use MacPorts in the same way) project that eases the installation of all software that Apple did not install on your OS, including Python and matplotlib. Under the hood, Homebrew is a set of Ruby and Git that automate download and installation. Following these instructions should get the installation working. First, we will install Homebrew, and then Python, followed by tools such as virtualenv, then dependencies for matplotlib (NumPy and SciPy), and finally matplotlib. Hold on, here we go.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After the command finishes, try running brew update or brew doctor to verify that the installation is working properly.
Homebrew
directory to your system path, so the packages you install using Homebrew have greater priority than other versions. Open ~/.bash_profile
(or /Users/[your-user-name]/.bash_profile
) and add the following line to the end of file:export PATH=/usr/local/bin:$PATH
brew install python --framework --universal
This will also install any prerequisites required by Python.
export PATH=/usr/local/share/python:/usr/local/bin:$PATH
python --version
in the command line, you should see 2.7.3 as the version number in the response.easy_install
to add pip:$ easy_install pip
virtualenv
and virtualenvwrapper
are useful:pip install virtualenv pip install virtualenvwrapper
pip install numpy brew install gfortran pip install scipy
import numpy print numpy.__version__ import scipy print scipy.__version__ quit()
matplotlib
:pip install matplotlib