|
| 1 | +********** |
| 2 | +Installing |
| 3 | +********** |
| 4 | + |
| 5 | +There are lots of different ways to install matplotlib, and the best |
| 6 | +way depends on what operating system you are using, what you already |
| 7 | +have installed, and how you want to use it. To avoid wading through |
| 8 | +all the details (and potential complications) on this page, the |
| 9 | +easiest thing for you to do is use one of the pre-packaged python |
| 10 | +distributions that already provide matplotlib built-in. The Enthought |
| 11 | +Python Distribution `(EPD) |
| 12 | +<http://www.enthought.com/products/epd.php>`_ for Windows, OS X or |
| 13 | +Redhat is an excellent choice that "just works" out of the box. |
| 14 | +Another excellent alternative for Windows users is `Python (x, y) |
| 15 | +<http://www.pythonxy.com/foreword.php>`_ which tends to be updated a |
| 16 | +bit more frequently. Both of these packages include matplotlib and |
| 17 | +pylab, and *lots* of other useful tools. matplotlib is also packaged |
| 18 | +for almost every major Linux distribution. So if you are on Linux, |
| 19 | +your package manager will probably provide matplotlib prebuilt. |
| 20 | + |
| 21 | + |
| 22 | +Manually installing pre-built packages |
| 23 | +====================================== |
| 24 | + |
| 25 | +General instructions |
| 26 | +-------------------- |
| 27 | + |
| 28 | +For some people, the prepackaged pythons discussed above are not an |
| 29 | +option. That's OK, it's usually pretty easy to get a custom install |
| 30 | +working. You will first need to find out if you have python installed |
| 31 | +on your machine, and if not, install it. The official python builds |
| 32 | +are available for download `here <http://www.python.org/download>`_, |
| 33 | +but OS X users please read :ref:`which-python-for-osx`. |
| 34 | + |
| 35 | +Once you have python up and running, you will need to install `numpy |
| 36 | +<http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`_. |
| 37 | +numpy provides high-performance array data structures and mathematical |
| 38 | +functions, and is a requirement for matplotlib. You can test your |
| 39 | +progress:: |
| 40 | + |
| 41 | + >>> import numpy |
| 42 | + >>> print numpy.__version__ |
| 43 | + |
| 44 | +matplotlib requires numpy version 1.1 or later. Although it is not a |
| 45 | +requirement to use matplotlib, we strongly encourage you to install |
| 46 | +`ipython <http://ipython.scipy.org/dist>`_, which is an interactive |
| 47 | +shell for python that is matplotlib-aware. |
| 48 | + |
| 49 | +Next, we need to get matplotlib installed. We provide prebuilt |
| 50 | +binaries for OS X and Windows on the matplotlib `download |
| 51 | +<http://sourceforge.net/projects/matplotlib/files/>`_ page. Click on |
| 52 | +the latest release of the "matplotlib" package, choose your python |
| 53 | +version (e.g., 2.5, 2.6 or 2.7) and your platform (macosx or win32). |
| 54 | +If you have any problems, please check the :ref:`installing-faq`, |
| 55 | +search using Google, and/or post a question to the `mailing list |
| 56 | +<http://sourceforge.net/project/showfiles.php?group_id=80706>`_. |
| 57 | + |
| 58 | +If you are on Debian/Ubuntu Linux, it suffices to do:: |
| 59 | + |
| 60 | + > sudo apt-get install python-matplotlib |
| 61 | + |
| 62 | +Instructions for installing our OSX binaries are found in the FAQ |
| 63 | +:ref:`install_osx_binaries`. |
| 64 | + |
| 65 | + |
| 66 | +Once you have ipython, numpy and matplotlib installed, you can use |
| 67 | +ipython's "pylab" mode to have a MATLAB-like environment that automatically |
| 68 | +handles most of the configuration details for you, so you can get up |
| 69 | +and running quickly:: |
| 70 | + |
| 71 | + johnh@flag:~> ipython -pylab |
| 72 | + Python 2.4.5 (#4, Apr 12 2008, 09:09:16) |
| 73 | + IPython 0.9.0 -- An enhanced Interactive Python. |
| 74 | + |
| 75 | + Welcome to pylab, a matplotlib-based Python environment. |
| 76 | + For more information, type 'help(pylab)'. |
| 77 | + |
| 78 | + In [1]: x = randn(10000) |
| 79 | + |
| 80 | + In [2]: hist(x, 100) |
| 81 | + |
| 82 | +Note that when testing matplotlib installations from the interactive |
| 83 | +python console, there are some issues relating to user interface |
| 84 | +toolkits and interactive settings that are discussed in |
| 85 | +:ref:`mpl-shell`. |
| 86 | + |
| 87 | +Installing on Windows |
| 88 | +--------------------- |
| 89 | + |
| 90 | +If you don't already have python installed, you may want to consider |
| 91 | +using the Enthought edition of python, which has scipy, numpy, and |
| 92 | +wxpython, plus many other useful packages, preinstalled - `Enthought |
| 93 | +Python <http://www.enthought.com/python>`_. With the Enthought |
| 94 | +edition of python + matplotlib installer, the following backends |
| 95 | +should work out of the box: agg, wx, wxagg, tkagg, ps, pdf and svg. |
| 96 | + |
| 97 | +For standard python installations, you will also need to install numpy |
| 98 | +in addition to the matplotlib installer. On some systems you will |
| 99 | +also need to download msvcp71.dll library, which you can download from |
| 100 | +http://www.dll-files.com/dllindex/dll-files.shtml?msvcp71 or other |
| 101 | +sites. You will need to unzip the archive and drag the dll into |
| 102 | +:file:`c:\windows\system32`. |
| 103 | + |
| 104 | +All of the GUI backends run on Windows, but TkAgg is probably the |
| 105 | +best for interactive use from the standard python shell or ipython. |
| 106 | +The Windows installer (:file:`*.exe`) on the download page contains all the |
| 107 | +code you need to get up and running. However, there are many |
| 108 | +examples that are not included in the Windows installer. If you |
| 109 | +want to try the many demos that come in the matplotlib source |
| 110 | +distribution, download the zip file and look in the :file:`examples` |
| 111 | +subdirectory. |
| 112 | + |
| 113 | +.. _install_from_source: |
| 114 | + |
| 115 | +Installing from source |
| 116 | +====================== |
| 117 | + |
| 118 | +If you are interested in contributing to matplotlib |
| 119 | +development, running the latest source code, or just like to |
| 120 | +build everything yourself, it is not difficult to build matplotlib |
| 121 | +from source. Grab the latest *tar.gz* release file from `sourceforge |
| 122 | +<http://sourceforge.net/project/showfiles.php?group_id=80706>`_, or if |
| 123 | +you want to develop matplotlib or just need the latest bugfixed |
| 124 | +version, grab the latest git version :ref:`install-from-git`. |
| 125 | + |
| 126 | +Once you have satisfied the requirements detailed below (mainly |
| 127 | +python, numpy, libpng and freetype), you can build matplotlib:: |
| 128 | + |
| 129 | + cd matplotlib |
| 130 | + python setup.py build |
| 131 | + python setup.py install |
| 132 | + |
| 133 | +We provide a `setup.cfg |
| 134 | +<https://github.com/matplotlib/matplotlib/raw/master/setup.cfg.template>`_ |
| 135 | +file that goes with :file:`setup.py` which you can use to customize |
| 136 | +the build process. For example, which default backend to use, whether |
| 137 | +some of the optional libraries that matplotlib ships with are |
| 138 | +installed, and so on. This file will be particularly useful to those |
| 139 | +packaging matplotlib. |
| 140 | + |
| 141 | +If you have installed prerequisites to nonstandard places and need to |
| 142 | +inform matplotlib where they are, edit ``setupext.py`` and add the base |
| 143 | +dirs to the ``basedir`` dictionary entry for your ``sys.platform``. |
| 144 | +e.g., if the header to some required library is in |
| 145 | +``/some/path/include/someheader.h``, put ``/some/path`` in the |
| 146 | +``basedir`` list for your platform. |
| 147 | + |
| 148 | +.. _install_requirements: |
| 149 | + |
| 150 | +Build requirements |
| 151 | +================== |
| 152 | + |
| 153 | +These are external packages which you will need to install before |
| 154 | +installing matplotlib. Windows users only need the first two (python |
| 155 | +and numpy) since the others are built into the matplotlib Windows |
| 156 | +installers available for download at the sourceforge site. If you are |
| 157 | +building on OSX, see :ref:`build_osx`. If you are installing |
| 158 | +dependencies with a package manager on Linux, you may need to install the |
| 159 | +development packages (look for a "-dev" postfix) in addition to the |
| 160 | +libraries themselves. |
| 161 | + |
| 162 | +.. note:: |
| 163 | + |
| 164 | + If you are on debian/ubuntu, you can get all the dependencies |
| 165 | + required to build matplotlib with:: |
| 166 | + |
| 167 | + sudo apt-get build-dep python-matplotlib |
| 168 | + |
| 169 | + If you are on Fedora/RedHat, you can get all the dependencies |
| 170 | + required to build matplotlib by first installing ``yum-builddep`` |
| 171 | + and then running:: |
| 172 | + |
| 173 | + su -c "yum-builddep python-matplotlib" |
| 174 | + |
| 175 | + This does not build matplotlib, but it does get the install the |
| 176 | + build dependencies, which will make building from source easier. |
| 177 | + |
| 178 | +:term:`python` 2.4 (or later but not python3) |
| 179 | + matplotlib requires python 2.4 or later (`download <http://www.python.org/download/>`__) |
| 180 | + |
| 181 | +:term:`numpy` 1.1 (or later) |
| 182 | + array support for python (`download |
| 183 | + <http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`__) |
| 184 | + |
| 185 | +libpng 1.2 (or later) |
| 186 | + library for loading and saving :term:`PNG` files (`download |
| 187 | + <http://www.libpng.org/pub/png/libpng.html>`__). libpng requires |
| 188 | + zlib. If you are a Windows user, you can ignore this because we |
| 189 | + build support into the matplotlib single-click installer |
| 190 | + |
| 191 | +:term:`freetype` 1.4 (or later) |
| 192 | + library for reading true type font files. If you are a windows |
| 193 | + user, you can ignore this since we build support into the |
| 194 | + matplotlib single click installer. |
| 195 | + |
| 196 | +**Optional** |
| 197 | + |
| 198 | +These are optional packages which you may want to install to use |
| 199 | +matplotlib with a user interface toolkit. See |
| 200 | +:ref:`what-is-a-backend` for more details on the optional matplotlib |
| 201 | +backends and the capabilities they provide. |
| 202 | + |
| 203 | +:term:`tk` 8.3 or later |
| 204 | + The TCL/Tk widgets library used by the TkAgg backend |
| 205 | + |
| 206 | +:term:`pyqt` 3.1 or later |
| 207 | + The Qt3 widgets library python wrappers for the QtAgg backend |
| 208 | + |
| 209 | +:term:`pyqt` 4.0 or later |
| 210 | + The Qt4 widgets library python wrappers for the Qt4Agg backend |
| 211 | + |
| 212 | +:term:`pygtk` 2.4 or later |
| 213 | + The python wrappers for the GTK widgets library for use with the |
| 214 | + GTK or GTKAgg backend |
| 215 | + |
| 216 | +:term:`wxpython` 2.8 or later |
| 217 | + The python wrappers for the wx widgets library for use with the |
| 218 | + WX or WXAgg backend |
| 219 | + |
| 220 | +:term:`pyfltk` 1.0 or later |
| 221 | + The python wrappers of the FLTK widgets library for use with FLTKAgg |
| 222 | + |
| 223 | +**Required libraries that ship with matplotlib** |
| 224 | + |
| 225 | +:term:`agg` 2.4 |
| 226 | + The antigrain C++ rendering engine. matplotlib links against the |
| 227 | + agg template source statically, so it will not affect anything on |
| 228 | + your system outside of matplotlib. |
| 229 | + |
| 230 | +:term:`pytz` 2007g or later |
| 231 | + timezone handling for python datetime objects. By default, |
| 232 | + matplotlib will install pytz if it isn't already installed on your |
| 233 | + system. To override the default, use :file:`setup.cfg` to force or |
| 234 | + prevent installation of pytz. |
| 235 | + |
| 236 | +:term:`dateutil` 1.1 or later |
| 237 | + provides extensions to python datetime handling. By default, matplotlib |
| 238 | + will install dateutil if it isn't already installed on your |
| 239 | + system. To override the default, use :file:`setup.cfg` to force |
| 240 | + or prevent installation of dateutil. |
| 241 | + |
| 242 | +.. _build_osx: |
| 243 | + |
| 244 | +Building on OSX |
| 245 | +=============== |
| 246 | + |
| 247 | +The build situation on OSX is complicated by the various places one |
| 248 | +can get the libpng and freetype requirements (darwinports, fink, |
| 249 | +/usr/X11R6) and the different architectures (e.g., x86, ppc, universal) and |
| 250 | +the different OSX version (e.g., 10.4 and 10.5). We recommend that you build |
| 251 | +the way we do for the OSX release: get the source from the tarball or the |
| 252 | +git repository and follow the instruction in :file:`README.osx`. |
| 253 | + |
0 commit comments