|
| 1 | +.. The source of this document is INSTALL. During the doc build process, |
| 2 | +.. this file is copied over to doc/users/installing.rst. |
| 3 | +.. Therefore, you must edit INSTALL, *not* doc/users/installing.rst! |
| 4 | +.. _pip: https://pypi.python.org/pypi/pip/ |
| 5 | + |
| 6 | +********** |
| 7 | +Installing |
| 8 | +********** |
| 9 | + |
| 10 | +There are many different ways to install matplotlib, and the best way |
| 11 | +depends on what operating system you are using, what you already have |
| 12 | +installed, and how you want to use it. To avoid wading through all |
| 13 | +the details (and potential complications) on this page, there are several |
| 14 | +convenient options. |
| 15 | + |
| 16 | +Installing pre-built packages |
| 17 | +============================= |
| 18 | + |
| 19 | +Most platforms : scientific Python distributions |
| 20 | +------------------------------------------------ |
| 21 | + |
| 22 | +The first option is to use one of the pre-packaged python |
| 23 | +distributions that already provide matplotlib built-in. The |
| 24 | +Continuum.io Python distribution (`Anaconda |
| 25 | +<https://www.continuum.io/downloads/>`_ or `miniconda |
| 26 | +<http://conda.pydata.org/miniconda.html>`_) and the Enthought |
| 27 | +distribution `(Canopy) <https://www.enthought.com/products/canopy/>`_ |
| 28 | +are both excellent choices that "just work" out of the box for |
| 29 | +Windows, OSX and common Linux platforms. Both of these distributions |
| 30 | +include matplotlib and *lots* of other useful tools. |
| 31 | + |
| 32 | + |
| 33 | +Linux : using your package manager |
| 34 | +---------------------------------- |
| 35 | + |
| 36 | +If you are on Linux, you might prefer to use your package manager. matplotlib |
| 37 | +is packaged for almost every major Linux distribution. |
| 38 | + |
| 39 | +* Debian / Ubuntu : ``sudo apt-get install python-matplotlib`` |
| 40 | +* Fedora / Redhat : ``sudo yum install python-matplotlib`` |
| 41 | + |
| 42 | +Mac OSX : using pip |
| 43 | +------------------- |
| 44 | + |
| 45 | +If you are on Mac OSX you can probably install matplotlib binaries using the |
| 46 | +standard Python installation program pip_. |
| 47 | +See :ref:`install_osx_binaries`. |
| 48 | + |
| 49 | +.. _installing_windows: |
| 50 | + |
| 51 | +Windows |
| 52 | +------- |
| 53 | + |
| 54 | +If you don't already have Python installed, we recommend using |
| 55 | +one of the `scipy-stack compatible Python distributions |
| 56 | +<http://www.scipy.org/install.html>`_ such as WinPython, Python(x,y), |
| 57 | +Enthought Canopy, or Continuum Anaconda, which have matplotlib and many |
| 58 | +of its dependencies, plus other useful packages, preinstalled. |
| 59 | + |
| 60 | +For `standard Python <https://www.python.org/download/>`_ installations, |
| 61 | +install matplotlib using pip_:: |
| 62 | + |
| 63 | + python -m pip install -U pip setuptools |
| 64 | + python -m pip install matplotlib |
| 65 | + |
| 66 | +In case Python 2.7 or 3.4 are not installed for all users, |
| 67 | +the Microsoft Visual C++ 2008 ( |
| 68 | +`64 bit <http://www.microsoft.com/download/en/details.aspx?id=15336>`__ |
| 69 | +or |
| 70 | +`32 bit <http://www.microsoft.com/download/en/details.aspx?id=29>`__ |
| 71 | +for Python 2.7) or Microsoft Visual C++ 2010 ( |
| 72 | +`64 bit <http://www.microsoft.com/en-us/download/details.aspx?id=14632>`__ |
| 73 | +or |
| 74 | +`32 bit <http://www.microsoft.com/en-us/download/details.aspx?id=5555>`__ |
| 75 | +for Python 3.4) redistributable packages need to be installed. |
| 76 | + |
| 77 | +Matplotlib depends on `Pillow <https://pypi.python.org/pypi/Pillow>`_ |
| 78 | +for reading and saving JPEG, BMP, and TIFF image files. |
| 79 | +Matplotlib requires `MiKTeX <http://miktex.org/>`_ and |
| 80 | +`GhostScript <http://www.ghostscript.com/download/>`_ for rendering text |
| 81 | +with LaTeX. |
| 82 | +`FFmpeg <https://www.ffmpeg.org/>`_, `avconv <https://libav.org/>`_, |
| 83 | +`mencoder <http://www.mplayerhq.hu>`_, or |
| 84 | +`ImageMagick <http://www.imagemagick.org/>`_ are required for the |
| 85 | +animation module. |
| 86 | + |
| 87 | +The following backends should work out of the box: agg, tkagg, ps, |
| 88 | +pdf and svg. |
| 89 | +For other backends you may need to install |
| 90 | +`pycairo <https://pypi.python.org/pypi/pycairo>`_, |
| 91 | +`PyQt4 <https://pypi.python.org/pypi/PyQt4>`_, |
| 92 | +`PyQt5 <https://pypi.python.org/pypi/PyQt5>`_, |
| 93 | +`PySide <https://pypi.python.org/pypi/PySide>`_, |
| 94 | +`wxPython <https://pypi.python.org/pypi/wxPython>`_, |
| 95 | +`PyGTK <https://pypi.python.org/pypi/PyGTK>`_, |
| 96 | +`Tornado <https://pypi.python.org/pypi/tornado>`_, |
| 97 | +or GhostScript. |
| 98 | + |
| 99 | +TkAgg is probably the best backend for interactive use from the |
| 100 | +standard Python shell or IPython. It is enabled as the default backend |
| 101 | +for the official binaries. GTK3 is not supported on Windows. |
| 102 | + |
| 103 | +The Windows wheels (:file:`*.whl`) on the `PyPI download page |
| 104 | +<https://pypi.python.org/pypi/matplotlib/>`_ do not contain test data |
| 105 | +or example code. |
| 106 | +If you want to try the many demos that come in the matplotlib source |
| 107 | +distribution, download the :file:`*.tar.gz` file and look in the |
| 108 | +:file:`examples` subdirectory. |
| 109 | +To run the test suite, copy the :file:`lib\\matplotlib\\tests` and |
| 110 | +:file:`lib\\mpl_toolkits\\tests` directories from the source |
| 111 | +distribution to :file:`sys.prefix\\Lib\\site-packages\\matplotlib` and |
| 112 | +:file:`sys.prefix\\Lib\\site-packages\\mpl_toolkits` respectively, and |
| 113 | +install `nose <https://pypi.python.org/pypi/nose>`_, `mock |
| 114 | +<https://pypi.python.org/pypi/mock>`_, Pillow, MiKTeX, GhostScript, |
| 115 | +ffmpeg, avconv, mencoder, ImageMagick, and `Inkscape |
| 116 | +<https://inkscape.org/>`_. |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | +.. _install_from_source: |
| 121 | + |
| 122 | +Installing from source |
| 123 | +====================== |
| 124 | + |
| 125 | +If you are interested in contributing to matplotlib development, |
| 126 | +running the latest source code, or just like to build everything |
| 127 | +yourself, it is not difficult to build matplotlib from source. Grab |
| 128 | +the latest *tar.gz* release file from `the PyPI files page |
| 129 | +<https://pypi.python.org/pypi/matplotlib/>`_, or if you want to |
| 130 | +develop matplotlib or just need the latest bugfixed version, grab the |
| 131 | +latest git version :ref:`install-from-git`. |
| 132 | + |
| 133 | +The standard environment variables `CC`, `CXX`, `PKG_CONFIG` are respected. |
| 134 | +This means you can set them if your toolchain is prefixed. This may be used for |
| 135 | +cross compiling. |
| 136 | + |
| 137 | + export CC=x86_64-pc-linux-gnu-gcc |
| 138 | + export CXX=x86_64-pc-linux-gnu-g++ |
| 139 | + export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config |
| 140 | + |
| 141 | +Once you have satisfied the requirements detailed below (mainly |
| 142 | +python, numpy, libpng and freetype), you can build matplotlib:: |
| 143 | + |
| 144 | + cd matplotlib |
| 145 | + python setup.py build |
| 146 | + python setup.py install |
| 147 | + |
| 148 | +We provide a `setup.cfg |
| 149 | +<https://github.com/matplotlib/matplotlib/raw/master/setup.cfg.template>`_ |
| 150 | +file that goes with :file:`setup.py` which you can use to customize |
| 151 | +the build process. For example, which default backend to use, whether |
| 152 | +some of the optional libraries that matplotlib ships with are |
| 153 | +installed, and so on. This file will be particularly useful to those |
| 154 | +packaging matplotlib. |
| 155 | + |
| 156 | +If you have installed prerequisites to nonstandard places and need to |
| 157 | +inform matplotlib where they are, edit ``setupext.py`` and add the base |
| 158 | +dirs to the ``basedir`` dictionary entry for your ``sys.platform``. |
| 159 | +e.g., if the header to some required library is in |
| 160 | +``/some/path/include/someheader.h``, put ``/some/path`` in the |
| 161 | +``basedir`` list for your platform. |
| 162 | + |
| 163 | +.. _install_requirements: |
| 164 | + |
| 165 | +Build requirements |
| 166 | +------------------ |
| 167 | + |
| 168 | +These are external packages which you will need to install before |
| 169 | +installing matplotlib. If you are building on OSX, see |
| 170 | +:ref:`build_osx`. If you are building on Windows, see |
| 171 | +:ref:`build_windows`. If you are installing dependencies with a |
| 172 | +package manager on Linux, you may need to install the development |
| 173 | +packages (look for a "-dev" postfix) in addition to the libraries |
| 174 | +themselves. |
| 175 | + |
| 176 | + |
| 177 | +Required Dependencies |
| 178 | +^^^^^^^^^^^^^^^^^^^^^ |
| 179 | + |
| 180 | +:term:`python` 2.7, 3.4, or 3.5 |
| 181 | + `Download python <http://www.python.org/download/>`_. |
| 182 | + |
| 183 | +:term:`numpy` |minimum_numpy_version| (or later) |
| 184 | + array support for python (`download numpy <http://numpy.org>`_) |
| 185 | + |
| 186 | +`setuptools <http://pythonhosted.org/setuptools/>`__ |
| 187 | + Setuptools provides extensions for python package installation. |
| 188 | + |
| 189 | +:term:`dateutil` 1.1 or later |
| 190 | + Provides extensions to python datetime handling. If using pip, |
| 191 | + easy_install or installing from source, the installer will attempt |
| 192 | + to download and install `python_dateutil` from PyPI. |
| 193 | + |
| 194 | +`pyparsing <https://pyparsing.wikispaces.com/>`__ |
| 195 | + Required for matplotlib's mathtext math rendering support. If |
| 196 | + using pip, easy_install or installing from source, the installer |
| 197 | + will attempt to download and install `pyparsing` from PyPI. |
| 198 | + |
| 199 | +`libpng 1.2 (or later) <http://www.libpng.org>`__ |
| 200 | + library for loading and saving :term:`PNG` files (`download |
| 201 | + <http://www.libpng.org/pub/png/libpng.html>`__). libpng requires |
| 202 | + zlib. |
| 203 | + |
| 204 | +`pytz <http://pytz.sourceforge.net/>`__ |
| 205 | + Used to manipulate time-zone aware datetimes. http://pypi.python.org/pypi/pytz |
| 206 | + |
| 207 | +:term:`FreeType` 2.3 or later |
| 208 | + Library for reading true type font files. If using pip, easy_install or |
| 209 | + installing from source, the installer will attempt to locate FreeType in |
| 210 | + expected locations. If it cannot, try installing `pkg-config |
| 211 | + <http://matplotlib.org/users/installing.html#optional-dependencies>`__, |
| 212 | + a tool used to find required non-python libraries. |
| 213 | + |
| 214 | +`cycler <http://matplotlib.org/cycler/>`__ 0.10.0 or later |
| 215 | + Composable cycle class used for constructing style-cycles |
| 216 | + |
| 217 | +`functools32` |
| 218 | + Required for compatibility if running on versions of Python before |
| 219 | + Python 3.2. |
| 220 | + |
| 221 | +Optional GUI framework |
| 222 | +^^^^^^^^^^^^^^^^^^^^^^ |
| 223 | + |
| 224 | +These are optional packages which you may want to install to use |
| 225 | +matplotlib with a user interface toolkit. See |
| 226 | +:ref:`what-is-a-backend` for more details on the optional matplotlib |
| 227 | +backends and the capabilities they provide. |
| 228 | + |
| 229 | +:term:`tk` 8.3 or later, not 8.6.0 or 8.6.1 |
| 230 | + The TCL/Tk widgets library used by the TkAgg backend. |
| 231 | + |
| 232 | + Versions 8.6.0 and 8.6.1 are known to have issues that may result |
| 233 | + in segfaults when closing multiple windows in the wrong order. |
| 234 | + |
| 235 | +:term:`pyqt` 4.4 or later |
| 236 | + The Qt4 widgets library python wrappers for the Qt4Agg backend |
| 237 | + |
| 238 | +:term:`pygtk` 2.4 or later |
| 239 | + The python wrappers for the GTK widgets library for use with the |
| 240 | + GTK or GTKAgg backend |
| 241 | + |
| 242 | +:term:`wxpython` 2.8 or later |
| 243 | + The python wrappers for the wx widgets library for use with the |
| 244 | + WX or WXAgg backend |
| 245 | + |
| 246 | +Optional external programs |
| 247 | +^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 248 | +`ffmpeg <https://www.ffmpeg.org/>`__/`avconv <https://libav.org/avconv.html>`__ or `mencoder <http://www.mplayerhq.hu/design7/news.html>`__ |
| 249 | + Required for the animation module to be save out put to movie |
| 250 | + formats. |
| 251 | + |
| 252 | +`ImageMagick <http://www.imagemagick.org/>`__ |
| 253 | + Required for the animation module to be able to save to animated gif. |
| 254 | + |
| 255 | +Optional dependencies |
| 256 | +^^^^^^^^^^^^^^^^^^^^^ |
| 257 | + |
| 258 | +`Pillow <http://python-pillow.github.io/>`__ |
| 259 | + If Pillow is installed, matplotlib can read and write a larger |
| 260 | + selection of image file formats. |
| 261 | + |
| 262 | +`pkg-config <http://www.freedesktop.org/wiki/Software/pkg-config/>`__ |
| 263 | + A tool used to find required non-python libraries. This is not strictly |
| 264 | + required, but can make installation go more smoothly if the libraries and |
| 265 | + headers are not in the expected locations. |
| 266 | + |
| 267 | + |
| 268 | +Required libraries that ship with matplotlib |
| 269 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 270 | +:term:`agg` 2.4 |
| 271 | + The antigrain C++ rendering engine. matplotlib links against the |
| 272 | + agg template source statically, so it will not affect anything on |
| 273 | + your system outside of matplotlib. |
| 274 | + |
| 275 | +`qhull` 2012.1 |
| 276 | + A library for computing Delaunay triangulations. |
| 277 | + |
| 278 | +`ttconv` |
| 279 | + truetype font utility |
| 280 | + |
| 281 | +six 1.9.0 |
| 282 | + Python 2/3 compatibility library. Do not use this in third-party |
| 283 | + code. |
| 284 | + |
| 285 | + |
| 286 | +.. _build_linux: |
| 287 | + |
| 288 | +Building on Linux |
| 289 | +----------------- |
| 290 | + |
| 291 | +It is easiest to use your system package manager to install the dependencies. |
| 292 | + |
| 293 | +If you are on Debian/Ubuntu, you can get all the dependencies |
| 294 | +required to build matplotlib with:: |
| 295 | + |
| 296 | + sudo apt-get build-dep python-matplotlib |
| 297 | + |
| 298 | +If you are on Fedora/RedHat, you can get all the dependencies required |
| 299 | +to build matplotlib by first installing ``yum-builddep`` and then |
| 300 | +running:: |
| 301 | + |
| 302 | + su -c "yum-builddep python-matplotlib" |
| 303 | + |
| 304 | +This does not build matplotlib, but it does get and install the |
| 305 | +build dependencies, which will make building from source easier. |
| 306 | + |
| 307 | + |
| 308 | +.. _build_osx: |
| 309 | + |
| 310 | +Building on OSX |
| 311 | +--------------- |
| 312 | + |
| 313 | +The build situation on OSX is complicated by the various places one |
| 314 | +can get the libpng and freetype requirements (darwinports, fink, |
| 315 | +/usr/X11R6) and the different architectures (e.g., x86, ppc, universal) and |
| 316 | +the different OSX version (e.g., 10.4 and 10.5). We recommend that you build |
| 317 | +the way we do for the OSX release: get the source from the tarball or the |
| 318 | +git repository and follow the instruction in :file:`README.osx`. |
| 319 | + |
| 320 | + |
| 321 | +.. _build_windows: |
| 322 | + |
| 323 | +Building on Windows |
| 324 | +------------------- |
| 325 | + |
| 326 | +The Python shipped from http://www.python.org is compiled with Visual Studio |
| 327 | +2008 for versions before 3.3, Visual Studio 2010 for 3.3 and 3.4, and |
| 328 | +Visual Studio 2015 for 3.5. Python extensions are recommended to be compiled |
| 329 | +with the same compiler. |
| 330 | + |
| 331 | +Since there is no canonical Windows package manager, the methods for building |
| 332 | +freetype, zlib, and libpng from source code are documented as a build script |
| 333 | +at `matplotlib-winbuild <https://github.com/jbmohler/matplotlib-winbuild>`_. |
0 commit comments