<divid="unreleased-message"> You are reading an old version of the documentation (v2.2.3). For the latest version see <ahref="https://matplotlib.org/stable/users/installing.html">https://matplotlib.org/stable/users/installing.html</a></div>
<h2><aclass="toc-backref" href="#id3">Installing an official release</a><aclass="headerlink" href="#installing-an-official-release" title="Permalink to this headline">¶</a></h2>
<p>Matplotlib and most of its dependencies are all available as wheel
packages for macOS, Windows and Linux distributions:</p>
<p>Although not required, we suggest also installing <codeclass="docutils literal notranslate"><spanclass="pre">IPython</span></code> for
interactive use. To easily install a complete Scientific Python
stack, see <aclass="reference internal" href="#install-scipy-dists"><spanclass="std std-ref">Scientific Python Distributions</span></a> below.</p>
<divclass="section" id="windows">
<spanid="installing-windows"></span><h3><aclass="toc-backref" href="#id4">Windows</a><aclass="headerlink" href="#windows" title="Permalink to this headline">¶</a></h3>
<p>In case Python 2.7 or 3.4 are not installed for all users,
<p>so that <em>subprocess32</em>, a dependency, may be compiled.</p>
<p>To use the native OSX backend you will need <aclass="reference internal" href="../faq/osx_framework.html#osxframework-faq"><spanclass="std std-ref">a framework build</span></a> build of Python.</p>
</div>
<divclass="section" id="linux">
<h3><aclass="toc-backref" href="#id6">Linux</a><aclass="headerlink" href="#linux" title="Permalink to this headline">¶</a></h3>
<p>On extremely old versions of Linux and Python 2.7 you may need to
install the master version of <em>subprocess32</em> (<aclass="reference external" href="https://github.com/google/python-subprocess32/issues/12#issuecomment-304724113">see comments</a>).</p>
</div>
<divclass="section" id="test-data">
<h3><aclass="toc-backref" href="#id7">Test Data</a><aclass="headerlink" href="#test-data" title="Permalink to this headline">¶</a></h3>
<p>The wheels (<codeclass="file docutils literal notranslate"><spanclass="pre">*.whl</span></code>) on the <aclass="reference external" href="https://pypi.python.org/pypi/matplotlib/">PyPI download page</a> 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 <codeclass="file docutils literal notranslate"><spanclass="pre">*.tar.gz</span></code> file and look in the
<h2><aclass="toc-backref" href="#id8">Third-party distributions of Matplotlib</a><aclass="headerlink" href="#third-party-distributions-of-matplotlib" title="Permalink to this headline">¶</a></h2>
<spanid="install-scipy-dists"></span><h3><aclass="toc-backref" href="#id9">Scientific Python Distributions</a><aclass="headerlink" href="#scientific-python-distributions" title="Permalink to this headline">¶</a></h3>
<p><aclass="reference external" href="https://www.continuum.io/downloads/">Anaconda</a> and <aclass="reference external" href="https://www.enthought.com/products/canopy/">Canopy</a> and <aclass="reference external" href="https://www.activestate.com/activepython/downloads">ActiveState</a> are excellent
choices that "just work" out of the box for Windows, macOS and common
Linux platforms. <aclass="reference external" href="https://winpython.github.io/">WinPython</a> is an
option for windows users. All of these distributions include
Matplotlib and <em>lots</em> of other useful (data) science tools.</p>
<h3><aclass="toc-backref" href="#id10">Linux : using your package manager</a><aclass="headerlink" href="#linux-using-your-package-manager" title="Permalink to this headline">¶</a></h3>
<p>If you are on Linux, you might prefer to use your package manager. Matplotlib
is packaged for almost every major Linux distribution.</p>
<spanid="install-from-source"></span><h2><aclass="toc-backref" href="#id11">Installing from source</a><aclass="headerlink" href="#installing-from-source" title="Permalink to this headline">¶</a></h2>
<p>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 <em>tar.gz</em> release file from <aclass="reference external" href="https://pypi.python.org/pypi/matplotlib/">the PyPI files page</a>, or if you want to
develop Matplotlib or just need the latest bugfixed version, grab the
latest git version <aclass="reference internal" href="../faq/installing_faq.html#install-from-git"><spanclass="std std-ref">Install from source</span></a>.</p>
<p>We provide a <aclass="reference external" href="https://raw.githubusercontent.com/matplotlib/matplotlib/master/setup.cfg.template">setup.cfg</a> file 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.</p>
<p>If you have installed prerequisites to nonstandard places and need to
inform Matplotlib where they are, edit <codeclass="docutils literal notranslate"><spanclass="pre">setupext.py</span></code> and add the base
dirs to the <codeclass="docutils literal notranslate"><spanclass="pre">basedir</span></code> dictionary entry for your <codeclass="docutils literal notranslate"><spanclass="pre">sys.platform</span></code>;
e.g., if the header of some required library is in
<codeclass="docutils literal notranslate"><spanclass="pre">/some/path/include/someheader.h</span></code>, put <codeclass="docutils literal notranslate"><spanclass="pre">/some/path</span></code> in the
<codeclass="docutils literal notranslate"><spanclass="pre">basedir</span></code> list for your platform.</p>
<divclass="section" id="dependencies">
<spanid="install-requirements"></span><h3><aclass="toc-backref" href="#id12">Dependencies</a><aclass="headerlink" href="#dependencies" title="Permalink to this headline">¶</a></h3>
<p>Matplotlib requires a large number of dependencies:</p>
<blockquote>
<div><ulclass="simple">
<li><aclass="reference external" href="https://www.python.org/downloads/">Python</a> (>= 2.7 or >= 3.4)</li>
<p>Optionally, you can also install a number of packages to enable better user
interface toolkits. See <aclass="reference internal" href="../tutorials/introductory/usage.html#what-is-a-backend"><spanclass="std std-ref">What is a backend?</span></a> for more details on the
optional Matplotlib backends and the capabilities they provide.</p>
<blockquote>
<div><ulclass="simple">
<li><aclass="reference internal" href="../glossary/index.html#term-tk"><spanclass="xref std std-term">tk</span></a> (>= 8.3, != 8.6.0 or 8.6.1): for the Tk-based backends;</li>
<li><aclass="reference external" href="https://pypi.python.org/pypi/PyQt4">PyQt4</a> (>= 4.6) or
<aclass="reference external" href="https://pypi.python.org/pypi/PySide">PySide</a>: for the Qt4-based backend;</li>
<li><aclass="reference external" href="https://pypi.python.org/pypi/PyQt5">PyQt5</a>: for the Qt5-based backend;</li>
<li><aclass="reference internal" href="../glossary/index.html#term-pygtk"><spanclass="xref std std-term">pygtk</span></a> (>= 2.4): for the GTK and the GTKAgg backend;</li>
<li><aclass="reference internal" href="../glossary/index.html#term-wxpython"><spanclass="xref std std-term">wxpython</span></a> (>= 2.9 or later): for the WX or WXAgg backend;</li>
<li><aclass="reference external" href="https://pypi.python.org/pypi/pycairo">pycairo</a>: for GTK3Cairo;</li>
<li><aclass="reference external" href="https://pypi.python.org/pypi/tornado">Tornado</a>: for the WebAgg backend;</li>
</ul>
</div></blockquote>
<p>For better support of animation output format and image file formats, LaTeX,
etc., you can install the following:</p>
<blockquote>
<div><ulclass="simple">
<li><aclass="reference external" href="https://www.ffmpeg.org/">ffmpeg</a>/<aclass="reference external" href="https://libav.org/avconv.html">avconv</a>: for saving movies;</li>
<li><aclass="reference external" href="https://www.imagemagick.org/script/index.php">ImageMagick</a>: for saving
animated gifs;</li>
<li><aclass="reference external" href="https://pillow.readthedocs.io/en/latest/">Pillow</a> (>=2.0): for a larger selection of
image file formats: JPEG, BMP, and TIFF image files;</li>
<li><aclass="reference external" href="https://miktex.org/">LaTeX</a> and <aclass="reference external" href="https://ghostscript.com/download/">GhostScript</a> (for rendering text with LaTeX).</li>
</ul>
</div></blockquote>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">Matplotlib depends on a large number of non-Python libraries.
can be used to find required non-Python libraries and thus make the install
go more smoothly if the libraries and headers are not in the expected
locations.</p>
</div>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<p>The following libraries are shipped with Matplotlib:</p>
<blockquoteclass="last">
<div><ulclass="simple">
<li><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Agg</span></code>: the Anti-Grain Geometry C++ rendering engine;</li>
<li><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">qhull</span></code>: to compute Delaunay triangulation;</li>
<li><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ttconv</span></code>: a true type font utility.</li>
</ul>
</div></blockquote>
</div>
</div>
<divclass="section" id="building-on-linux">
<spanid="build-linux"></span><h3><aclass="toc-backref" href="#id13">Building on Linux</a><aclass="headerlink" href="#building-on-linux" title="Permalink to this headline">¶</a></h3>
<p>It is easiest to use your system package manager to install the dependencies.</p>
<p>If you are on Debian/Ubuntu, you can get all the dependencies
<p>These commands do not build Matplotlib, but instead get and install the
build dependencies, which will make building from source easier.</p>
</div>
<divclass="section" id="building-on-macos">
<spanid="build-osx"></span><h3><aclass="toc-backref" href="#id14">Building on macOS</a><aclass="headerlink" href="#building-on-macos" title="Permalink to this headline">¶</a></h3>
<p>The build situation on macOS is complicated by the various places one
can get the libpng and FreeType requirements (MacPorts, Fink,
/usr/X11R6), the different architectures (e.g., x86, ppc, universal), and
the different macOS versions (e.g., 10.4 and 10.5). We recommend that you build
the way we do for the macOS release: get the source from the tarball or the
git repository and install the required dependencies through a third-party
package manager. Two widely used package managers are Homebrew, and MacPorts.
The following example illustrates how to install libpng and FreeType using
<p>Note that your environment is somewhat important. Some conda users have
found that, to run the tests, their PYTHONPATH must include
/path/to/anaconda/.../site-packages and their DYLD_FALLBACK_LIBRARY_PATH
must include /path/to/anaconda/lib.</p>
</div>
<divclass="section" id="building-on-windows">
<spanid="build-windows"></span><h3><aclass="toc-backref" href="#id15">Building on Windows</a><aclass="headerlink" href="#building-on-windows" title="Permalink to this headline">¶</a></h3>
<p>The Python shipped from <aclass="reference external" href="https://www.python.org">https://www.python.org</a> is compiled with Visual Studio
2008 for versions before 3.3, Visual Studio 2010 for 3.3 and 3.4, and
Visual Studio 2015 for 3.5 and 3.6. Python extensions are recommended to be compiled
with the same compiler.</p>
<p>Since there is no canonical Windows package manager, the methods for building
FreeType, zlib, and libpng from source code are documented as a build script
at <aclass="reference external" href="https://github.com/jbmohler/matplotlib-winbuild">matplotlib-winbuild</a>.</p>
<p>There are a few possibilities to build Matplotlib on Windows:</p>
<ulclass="simple">
<li>Wheels via <aclass="reference external" href="https://github.com/jbmohler/matplotlib-winbuild">matplotlib-winbuild</a></li>
<h4><aclass="toc-backref" href="#id16">Wheel builds using conda packages</a><aclass="headerlink" href="#wheel-builds-using-conda-packages" title="Permalink to this headline">¶</a></h4>
<p>This is a wheel build, but we use conda packages to get all the requirements. The binary
requirements (png, FreeType,...) are statically linked and therefore not needed during the wheel
install.</p>
<p>The commands below assume that you can compile a native Python lib for the Python version of your
choice. See <aclass="reference external" href="https://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/">this howto</a>
for how to install and setup such environments. If in doubt: use Python >= 3.5 as it mostly works
without fiddling with environment variables:</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># create a new environment with the required packages</span>
<p>The <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">build_alllocal.cmd</span></code> script in the root folder automates these steps if
you have already created and activated the conda environment.</p>
</div>
<divclass="section" id="conda-packages">
<h4><aclass="toc-backref" href="#id17">Conda packages</a><aclass="headerlink" href="#conda-packages" title="Permalink to this headline">¶</a></h4>
<p>This needs a <aclass="reference external" href="https://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/">working installed C compiler</a>
for the version of Python you are compiling the package for but you don't need
to setup the environment variables:</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># only the first time...</span>