<divid="unreleased-message"> You are reading an old version of the documentation (v2.1.1). For the latest version see <ahref="/stable/">https://matplotlib.org/stable/</a></div>
<spanid="virtualenv-faq"></span><h1>Working with Matplotlib in Virtual environments<aclass="headerlink" href="#working-with-matplotlib-in-virtual-environments" title="Permalink to this headline">¶</a></h1>
<p>When running Matplotlib in a <aclass="reference external" href="https://virtualenv.pypa.io/en/latest/">virtual environment</a> you may discover a few issues.
Matplotlib itself has no issue with virtual environments. However, some of
the external GUI frameworks that Matplotlib uses for interactive figures may
be tricky to install in a virtual environment. Everything below assumes some
familiarity with the Matplotlib backends as found in <aclass="reference internal" href="../tutorials/introductory/usage.html#what-is-a-backend"><spanclass="std std-ref">What is a backend?</span></a>.</p>
<p>If you only use the IPython and Jupyter Notebook’s <codeclass="docutils literal"><spanclass="pre">inline</span></code> and <codeclass="docutils literal"><spanclass="pre">notebook</span></code>
backends, or non-interactive backends, you should not have any issues and can
ignore everything below.</p>
<p>Likewise, the <codeclass="docutils literal"><spanclass="pre">Tk</span></code> framework (<codeclass="docutils literal"><spanclass="pre">TkAgg</span></code> backend) does not require any
external dependencies and is normally always available. On certain Linux
distributions, a package named <codeclass="docutils literal"><spanclass="pre">python-tk</span></code> (or similar) needs to be
installed.</p>
<p>Otherwise, the situation (at the time of writing) is as follows:</p>
from within the virtualenv to specific system-wide packages without the
overall shadowing issue. A specific package needs to be installed for each
framework, e.g. <aclass="reference external" href="https://pypi.python.org/pypi/vext.pyqt5">vext.pyqt5</a>, etc.</li>
<li>The GUI frameworks can be manually symlinked into the environment, e.g. for
PyQt5, you should symlink <codeclass="docutils literal"><spanclass="pre">PyQt5</span></code> and <codeclass="docutils literal"><spanclass="pre">sip</span></code> from the system site-packages
into the virtualenv site-packages.</li>
</ul>
<p>If you are using Matplotlib on OSX, you may also want to consider the