When installing through a package manager like
mandatory dependencies are automatically installed. This list is mainly for
Python (>= 3.9)
contourpy (>= 1.0.1)
cycler (>= 0.10.0)
dateutil (>= 2.7)
fontTools (>= 4.22.0)
kiwisolver (>= 1.3.1)
NumPy (>= 1.21)
packaging (>= 20.0)
Pillow (>= 8.0)
pyparsing (>= 2.3.1)
pyparsing (>= 2.3.1)
importlib-resources (>= 3.2.0; only required on Python < 3.10)
The following packages and tools are not required but extend the capabilities of Matplotlib.
Matplotlib figures can be rendered to various user interfaces. See What is a backend? for more details on the optional Matplotlib backends and the capabilities they provide.
Tk (>= 8.5, != 8.6.0 or 8.6.1): for the Tk-based backends. Tk is part of most standard Python installations, but it's not part of Python itself and thus may not be present in rare cases.
PyQt6 (>= 6.1), PySide6, PyQt5, or PySide2: for the Qt-based backends.
PyGObject and pycairo (>= 1.14.0): for the GTK-based backends. If using pip (but not conda or system package manager) PyGObject must be built from source; see pygobject documentation.
pycairo (>= 1.14.0) or cairocffi (>= 0.8): for cairo-based backends.
wxPython (>= 4): for the wx-based backends. If using pip (but not conda or system package manager) on Linux wxPython wheels must be manually downloaded from https://wxpython.org/pages/downloads/.
Tornado (>= 5): for the WebAgg backend.
ipykernel: for the nbagg backend.
macOS (>= 10.12): for the macosx backend.
ffmpeg: for saving movies.
ImageMagick: for saving animated gifs.
Font handling and rendering#
LaTeX (with cm-super and underscore) and GhostScript (>= 9.0): for rendering text with LaTeX.
fontconfig (>= 2.7): for detection of system fonts on Linux.
Matplotlib brings its own copies of the following libraries:
Agg: the Anti-Grain Geometry C++ rendering engine
ttconv: a TrueType font utility
Additionally, Matplotlib depends on:
FreeType (>= 2.3): a font rendering library
QHull (>= 2020.2): a library for computing triangulations
By default, Matplotlib downloads and builds its own copies of FreeType (this is necessary to run the test suite, because different versions of FreeType rasterize characters differently) and of Qhull. As an exception, Matplotlib defaults to the system version of FreeType on AIX.
To force Matplotlib to use a copy of FreeType or Qhull already installed in
your system, create a
mplsetup.cfg file with the following contents:
[libs] system_freetype = true system_qhull = true
python -m pip install ..
In this case, you need to install the FreeType and Qhull library and headers. This can be achieved using a package manager, e.g. for FreeType:
# Pick ONE of the following: sudo apt install libfreetype6-dev # Debian/Ubuntu sudo dnf install freetype-devel # Fedora brew install freetype # macOS with Homebrew conda install freetype # conda, any OS
(adapt accordingly for Qhull).
On Linux and macOS, it is also recommended to install pkg-config, a helper tool for locating FreeType:
# Pick ONE of the following: sudo apt install pkg-config # Debian/Ubuntu sudo dnf install pkgconf # Fedora brew install pkg-config # macOS with Homebrew conda install pkg-config # conda # Or point the PKG_CONFIG environment variable to the path to pkg-config: export PKG_CONFIG=...
If not using pkg-config (in particular on Windows), you may need to set the include path (to the library headers) and link path (to the libraries) explicitly, if they are not in standard locations. This can be done using standard environment variables -- on Linux and OSX:
export CFLAGS='-I/directory/containing/ft2build.h' export LDFLAGS='-L/directory/containing/libfreetype.so'
and on Windows:
set CL=/IC:\directory\containing\ft2build.h set LINK=/LIBPATH:C:\directory\containing\freetype.lib
If you go this route but need to reset and rebuild to change your settings, remember to clear your artifacts before re-building:
git clean -xfd
Minimum pip / manylinux support (linux)#
Matplotlib publishes manylinux wheels which have a minimum version of pip which will recognize the wheels
manylinx2014/ pip >= 19.3
In all cases the required version of pip is embedded in the CPython source.
Dependencies for building Matplotlib#
certifi (>= 2020.06.20). Used while downloading the freetype and QHull source during build. This is not a runtime dependency.
setuptools_scm (>= 7). Used to update the reported
mpl.__version__based on the current git commit. Also a runtime dependency for editable installs.
NumPy (>= 1.21). Also a runtime dependency.
Matplotlib requires a C++ compiler that supports C++11.
gcc 4.8.1 or higher. For gcc <6.5 you will need to set
$CFLAGS=-std=c++11to enable C++11 support. Installing GCC: Binaries.
clang 3.3 or higher. LLVM Download Page.
Visual Studio 2015 (aka VS 14.0) or higher. A free version of Build Tools for Visual Studio is available for download.
Dependencies for testing Matplotlib#
This section lists the additional software required for running the tests.
pytest (>= 7.0.0)
In addition to all of the optional dependencies on the main library, for testing the following will be used if they are installed.
Ghostscript (>= 9.0, to render PDF files)
Inkscape (to render SVG files)
pandas used to test compatibility with Pandas
pikepdf used in some tests for the pgf and pdf backends
psutil used in testing the interactive backends
pytest-cov (>= 2.3.1) to collect coverage information
pytest-flake8 to test coding standards using flake8
pytest-timeout to limit runtime in case of stuck tests
pytest-xdist to run tests in parallel
pytest-xvfb to run tests without windows popping up (Linux)
pytz used to test pytz int
sphinx used to test our sphinx extensions
WenQuanYi Zen Hei and Noto Sans CJK fonts for testing font fallback and non-western fonts
xarray used to test compatibility with xarray
If any of these dependencies are not discovered the tests that rely on them will be skipped by pytest.
When installing Inkscape on Windows, make sure that you select “Add Inkscape to system PATH”, either for all users or current user, or the tests will not find it.
Dependencies for building Matplotlib's documentation#
The additional Python packages required to build the
documentation are listed in
doc-requirements.txt and can be installed using
pip install -r requirements/doc/doc-requirements.txt
The content of
doc-requirements.txt is also shown below:
# Requirements for building docs # # You will first need a matching Matplotlib installation # e.g (from the Matplotlib root directory) # pip install -e . # # Install the documentation requirements with: # pip install -r requirements/doc/doc-requirements.txt # sphinx>=3.0.0,!=6.1.2 colorspacious ipython ipywidgets ipykernel numpydoc>=1.0 packaging>=20 pydata-sphinx-theme~=0.13.1 mpl-sphinx-theme~=3.7.0 pyyaml sphinxcontrib-svg2pdfconverter>=1.1.0 sphinx-gallery>=0.12.0 sphinx-copybutton sphinx-design
Additional external dependencies#
a minimal working LaTeX distribution, e.g., TeX Live or MikTeX
the following LaTeX packages (if your OS bundles TeX Live, the "complete" version of the installer, e.g. "texlive-full" or "texlive-all", will often automatically include these packages):
Optional, but recommended:
the font "Humor Sans" (aka the "XKCD" font), or the free alternative Comic Neue
the font "Times New Roman"
The documentation will not build without LaTeX and Graphviz. These are not Python packages and must be installed separately. The documentation can be built without Inkscape and optipng, but the build process will raise various warnings. If the build process warns that you are missing fonts, make sure your LaTeX distribution bundles cm-super or install it separately.