Learn what to expect in the new updates
There are many different ways to install matplotlib, and the best way depends on what operating system you are using, what you already have installed, and how you want to use it. To avoid wading through all the details (and potential complications) on this page, there are several convenient options.
The first option is to use one of the pre-packaged python distributions that already provide matplotlib built-in. The Continuum.io Python distribution (Anaconda or miniconda) and the Enthought distribution (Canopy) are both excellent choices that “just work” out of the box for Windows, OSX and common Linux platforms. Both of these distributions include matplotlib and lots of other useful tools. Another excellent alternative for Windows users is Python (x, y) .
If you are on Linux, you might prefer to use your package manager. matplotlib is packaged for almost every major Linux distribution.
If you don’t already have Python installed, we recommend using one of the scipy-stack compatible Python distributions such as Python(x,y), Enthought Canopy, or Continuum Anaconda, which have matplotlib and many of its dependencies, plus other useful packages, preinstalled.
In case Python is not installed for all users (not the default), the Microsoft Visual C++ 2008 ( 64 bit or 32 bit for Python 2.6 to 3.2) or Microsoft Visual C++ 2010 ( 64 bit or 32 bit for Python 3.3 and 3.4) redistributable packages need to be installed.
Matplotlib depends on Pillow for reading and saving JPEG, BMP, and TIFF image files. Matplotlib requires MiKTeX and GhostScript for rendering text with LaTeX. FFmpeg, avconv, mencoder, or ImageMagick are required for the animation module.
TkAgg is probably the best backend for interactive use from the standard Python shell or IPython. It is enabled as the default backend for the official binaries. GTK3 is not supported on Windows.
The Windows installers (*.exe) and wheels (*.whl) on the download page do not contain test data or example code. If you want to try the many demos that come in the matplotlib source distribution, download the *.tar.gz file and look in the examples subdirectory. To run the test suite, copy the libmatplotlibtests and libmpl_toolkitstests directories from the source distribution to sys.prefixLibsite-packagesmatplotlib and sys.prefixLibsite-packagesmpl_toolkits respectively, and install nose, mock, Pillow, MiKTeX, GhostScript, ffmpeg, avconv, mencoder, ImageMagick, and Inkscape.
If you are interested in contributing to matplotlib development, running the latest source code, or just like to build everything yourself, it is not difficult to build matplotlib from source. Grab the latest tar.gz release file from the download page, or if you want to develop matplotlib or just need the latest bugfixed version, grab the latest git version Source install from git.
Once you have satisfied the requirements detailed below (mainly python, numpy, libpng and freetype), you can build matplotlib:
cd matplotlib python setup.py build python setup.py install
We provide a setup.cfg file that goes with setup.py which you can use to customize the build process. For example, which default backend to use, whether some of the optional libraries that matplotlib ships with are installed, and so on. This file will be particularly useful to those packaging matplotlib.
If you have installed prerequisites to nonstandard places and need to inform matplotlib where they are, edit setupext.py and add the base dirs to the basedir dictionary entry for your sys.platform. e.g., if the header to some required library is in /some/path/include/someheader.h, put /some/path in the basedir list for your platform.
These are external packages which you will need to install before installing matplotlib. If you are building on OSX, see Building on OSX. If you are building on Windows, see Building on Windows. If you are installing dependencies with a package manager on Linux, you may need to install the development packages (look for a “-dev” postfix) in addition to the libraries themselves.
These are optional packages which you may want to install to use matplotlib with a user interface toolkit. See What is a backend? for more details on the optional matplotlib backends and the capabilities they provide.
It is easiest to use your system package manager to install the dependencies.
If you are on Debian/Ubuntu, you can get all the dependencies required to build matplotlib with:
sudo apt-get build-dep python-matplotlib
If you are on Fedora/RedHat, you can get all the dependencies required to build matplotlib by first installing yum-builddep and then running:
su -c "yum-builddep python-matplotlib"
This does not build matplotlib, but it does get the install the build dependencies, which will make building from source easier.
The build situation on OSX is complicated by the various places one can get the libpng and freetype requirements (darwinports, fink, /usr/X11R6) and the different architectures (e.g., x86, ppc, universal) and the different OSX version (e.g., 10.4 and 10.5). We recommend that you build the way we do for the OSX release: get the source from the tarball or the git repository and follow the instruction in README.osx.
The Python shipped from http://www.python.org is compiled with Visual Studio 2008 for versions before 3.3 and Visual Studio 2010 for 3.3 and later. Python extensions are recommended to be compiled with the same compiler. The .NET Framework 4.0 is required for MSBuild (you’ll likely have the requisite Framework with Visual Studio). In addition to Visual Studio CMake is required for building libpng.
Since there is no canonical Windows package manager the build methods for freetype, zlib, libpng, tcl, & tk source code are documented as a build script at matplotlib-winbuild.