File: virtualenv_faq.rst

package info (click to toggle)
matplotlib 3.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 77,480 kB
  • sloc: python: 124,525; cpp: 58,549; ansic: 29,599; objc: 2,348; makefile: 148; sh: 57
file content (64 lines) | stat: -rw-r--r-- 3,199 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
.. _virtualenv-faq:

***********************************************
Working with Matplotlib in Virtual environments
***********************************************

While Matplotlib itself runs fine in a `virtual environment
<https://docs.python.org/3/library/venv.html>`_ (venv), some of the GUI
frameworks that Matplotlib uses for interactive figures are tricky to install
in a venv.  Everything below assumes some familiarity with the Matplotlib
backends as found in :ref:`What is a backend? <what-is-a-backend>`.

If you only use the IPython and Jupyter Notebook's ``inline`` and ``notebook``
backends, or non-interactive backends, you should not have any issues and can
ignore everything below.

Likewise, the ``Tk`` framework (``TkAgg`` backend) does not require any
external dependencies and is normally always available.  On certain Linux
distributions, a package named ``python-tk`` (or similar) needs to be
installed.

Otherwise, the situation (at the time of writing) is as follows:

========= ========= ================ =================================
framework bindings  pip-installable? conda or conda-forge-installable?
========= ========= ================ =================================
Qt5       PyQt5     yes              yes
Qt5       PySide2   yes              yes
Qt4       PyQt4     no               yes
Qt4       PySide    OSX and Windows  yes
GTK3      PyGObject yes [#]_         Linux and OSX
wxWidgets wxPython  yes [#]_         yes
========= ========= ================ =================================

.. [#] No wheels available, see
       https://pygobject.readthedocs.io/en/latest/devguide/dev_environ.html
       for build instructions.

.. [#] OSX and Windows wheels available on PyPI.  Linux wheels available but
       not on PyPI, see https://wxpython.org/pages/downloads/.

For cases where the framework is not installable in a venv, it needs to be
installed in the global (system) site-packages, and then made available from
within the venv.  This can be achieved by either of the following methods (in
all cases, the system-wide Python and the venv Python must be of the same
version):

- `vext <https://pypi.python.org/pypi/vext>`_ allows controlled access
  from within the venv to specific system-wide packages.  A specific
  package needs to be installed for each framework, e.g. `vext.pyqt5
  <https://pypi.python.org/pypi/vext.pyqt5>`_, etc.  It is recommended to use
  ``vext>=0.7.0`` as earlier versions misconfigure the logging system.

- Using the ``--system-site-packages`` option when creating an environment
  adds all system-wide packages to the virtual environment.  However, this
  breaks the isolation between the virtual environment and the system
  install.  Among other issues it results in hard to debug problems with
  system packages shadowing the environment packages.  If you use `virtualenv
  <https://virtualenv.pypa.io/>` (rather than the stdlib's ``venv``) together
  with `virtualenvwrapper <https://virtualenvwrapper.readthedocs.io/>`_, this
  can be toggled with the ``toggleglobalsitepackages`` command.

If you are using Matplotlib on OSX, you may also want to consider the
:ref:`OSX framework FAQ <osxframework-faq>`.