|
1 |
| -.. _installing-faq: |
| 1 | +.. redirect-from:: /users/installing/index |
| 2 | + |
| 3 | +############ |
| 4 | +Installation |
| 5 | +############ |
| 6 | + |
| 7 | +============================== |
| 8 | +Installing an official release |
| 9 | +============================== |
| 10 | + |
| 11 | +Matplotlib releases are available as wheel packages for macOS, Windows and |
| 12 | +Linux on `PyPI <https://pypi.org/project/matplotlib/>`_. Install it using |
| 13 | +``pip``: |
| 14 | + |
| 15 | +.. code-block:: sh |
| 16 | +
|
| 17 | + python -m pip install -U pip |
| 18 | + python -m pip install -U matplotlib |
| 19 | +
|
| 20 | +If this command results in Matplotlib being compiled from source and |
| 21 | +there's trouble with the compilation, you can add ``--prefer-binary`` to |
| 22 | +select the newest version of Matplotlib for which there is a |
| 23 | +precompiled wheel for your OS and Python. |
| 24 | + |
| 25 | +.. note:: |
| 26 | + |
| 27 | + The following backends work out of the box: Agg, ps, pdf, svg |
| 28 | + |
| 29 | + Python is typically shipped with tk bindings which are used by |
| 30 | + TkAgg. |
| 31 | + |
| 32 | + For support of other GUI frameworks, LaTeX rendering, saving |
| 33 | + animations and a larger selection of file formats, you can |
| 34 | + install :ref:`optional_dependencies`. |
| 35 | + |
| 36 | +========================= |
| 37 | +Third-party distributions |
| 38 | +========================= |
| 39 | + |
| 40 | +Various third-parties provide Matplotlib for their environments. |
| 41 | + |
| 42 | +Conda packages |
| 43 | +============== |
| 44 | +Matplotlib is available both via the *anaconda main channel* |
| 45 | + |
| 46 | +.. code-block:: sh |
| 47 | +
|
| 48 | + conda install matplotlib |
| 49 | +
|
| 50 | +as well as via the *conda-forge community channel* |
| 51 | + |
| 52 | +.. code-block:: sh |
| 53 | +
|
| 54 | + conda install -c conda-forge matplotlib |
| 55 | +
|
| 56 | +Python distributions |
| 57 | +==================== |
| 58 | + |
| 59 | +Matplotlib is part of major Python distributions: |
| 60 | + |
| 61 | +- `Anaconda <https://www.anaconda.com/>`_ |
| 62 | + |
| 63 | +- `ActiveState ActivePython |
| 64 | + <https://www.activestate.com/products/python/downloads/>`_ |
| 65 | + |
| 66 | +- `WinPython <https://winpython.github.io/>`_ |
| 67 | + |
| 68 | +Linux package manager |
| 69 | +===================== |
| 70 | + |
| 71 | +If you are using the Python version that comes with your Linux distribution, |
| 72 | +you can install Matplotlib via your package manager, e.g.: |
| 73 | + |
| 74 | +* Debian / Ubuntu: ``sudo apt-get install python3-matplotlib`` |
| 75 | +* Fedora: ``sudo dnf install python3-matplotlib`` |
| 76 | +* Red Hat: ``sudo yum install python3-matplotlib`` |
| 77 | +* Arch: ``sudo pacman -S python-matplotlib`` |
| 78 | + |
| 79 | +.. redirect-from:: /users/installing/installing_source |
| 80 | + |
| 81 | +.. _install_from_source: |
| 82 | + |
| 83 | +====================== |
| 84 | +Installing from source |
| 85 | +====================== |
| 86 | + |
| 87 | +If you are interested in contributing to Matplotlib development, |
| 88 | +running the latest source code, or just like to build everything |
| 89 | +yourself, it is not difficult to build Matplotlib from source. |
| 90 | + |
| 91 | +First you need to install the :ref:`dependencies`. |
| 92 | + |
| 93 | +A C compiler is required. Typically, on Linux, you will need ``gcc``, which |
| 94 | +should be installed using your distribution's package manager; on macOS, you |
| 95 | +will need xcode_; on Windows, you will need Visual Studio 2015 or later. |
| 96 | + |
| 97 | +.. _xcode: https://guide.macports.org/chunked/installing.html#installing.xcode |
| 98 | + |
| 99 | +The easiest way to get the latest development version to start contributing |
| 100 | +is to go to the git `repository <https://github.com/matplotlib/matplotlib>`_ |
| 101 | +and run:: |
| 102 | + |
| 103 | + git clone https://github.com/matplotlib/matplotlib.git |
| 104 | + |
| 105 | +or:: |
| 106 | + |
| 107 | + git clone [email protected]:matplotlib/matplotlib.git |
| 108 | + |
| 109 | +If you're developing, it's better to do it in editable mode. The reason why |
| 110 | +is that pytest's test discovery only works for Matplotlib |
| 111 | +if installation is done this way. Also, editable mode allows your code changes |
| 112 | +to be instantly propagated to your library code without reinstalling (though |
| 113 | +you will have to restart your python process / kernel):: |
| 114 | + |
| 115 | + cd matplotlib |
| 116 | + python -m pip install -e . |
| 117 | + |
| 118 | +If you're not developing, it can be installed from the source directory with |
| 119 | +a simple (just replace the last step):: |
| 120 | + |
| 121 | + python -m pip install . |
| 122 | + |
| 123 | +To run the tests you will need to install some additional dependencies:: |
| 124 | + |
| 125 | + python -m pip install -r requirements/dev/dev-requirements.txt |
| 126 | + |
| 127 | +Then, if you want to update your Matplotlib at any time, just do:: |
| 128 | + |
| 129 | + git pull |
| 130 | + |
| 131 | +When you run ``git pull``, if the output shows that only Python files have |
| 132 | +been updated, you are all set. If C files have changed, you need to run ``pip |
| 133 | +install -e .`` again to compile them. |
| 134 | + |
| 135 | +There is more information on :ref:`using git <using-git>` in the developer |
| 136 | +docs. |
| 137 | + |
| 138 | +.. warning:: |
| 139 | + |
| 140 | + The following instructions in this section are for very custom |
| 141 | + installations of Matplotlib. Proceed with caution because these instructions |
| 142 | + may result in your build producing unexpected behavior and/or causing |
| 143 | + local testing to fail. |
| 144 | + |
| 145 | +If you would like to build from a tarball, grab the latest *tar.gz* release |
| 146 | +file from `the PyPI files page <https://pypi.org/project/matplotlib/>`_. |
| 147 | + |
| 148 | +We provide a `mplsetup.cfg`_ file which you can use to customize the build |
| 149 | +process. For example, which default backend to use, whether some of the |
| 150 | +optional libraries that Matplotlib ships with are installed, and so on. This |
| 151 | +file will be particularly useful to those packaging Matplotlib. |
| 152 | + |
| 153 | +.. _mplsetup.cfg: https://raw.githubusercontent.com/matplotlib/matplotlib/main/mplsetup.cfg.template |
| 154 | + |
| 155 | +If you are building your own Matplotlib wheels (or sdists) on Windows, note |
| 156 | +that any DLLs that you copy into the source tree will be packaged too. |
| 157 | + |
| 158 | +========================== |
| 159 | +Installing for development |
| 160 | +========================== |
| 161 | +See :ref:`installing_for_devs`. |
2 | 162 |
|
3 | 163 | .. redirect-from:: /faq/installing_faq
|
| 164 | +.. redirect-from:: /users/faq/installing_faq |
| 165 | + |
| 166 | +.. _installing-faq: |
4 | 167 |
|
5 |
| -************** |
6 |
| -Installing FAQ |
7 |
| -************** |
| 168 | +========================== |
| 169 | +Frequently Asked Questions |
| 170 | +========================== |
8 | 171 |
|
9 | 172 | .. contents::
|
10 | 173 | :backlinks: none
|
| 174 | + :local: |
11 | 175 |
|
12 | 176 | Report a compilation problem
|
13 | 177 | ============================
|
|
0 commit comments