<divid="unreleased-message"> You are reading an old version of the documentation (v3.0.2). For the latest version see <ahref="/stable/">https://matplotlib.org/stable/</a></div>
<spanid="osxframework-faq"></span><h1>Working with Matplotlib on OSX<aclass="headerlink" href="#working-with-matplotlib-on-osx" title="Permalink to this headline">¶</a></h1>
<divclass="contents topic" id="contents">
<pclass="topic-title first">Contents</p>
<ulclass="simple">
<li><aclass="reference internal" href="#working-with-matplotlib-on-osx" id="id2">Working with Matplotlib on OSX</a><ul>
<spanid="osxframework-introduction"></span><h2>Introduction<aclass="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>On OSX, two different types of Python builds exist: a regular build and a
framework build. In order to interact correctly with OSX through the native
GUI frameworks, you need a framework build of Python. At the time of writing
the <codeclass="docutils literal notranslate"><spanclass="pre">macosx</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">WXAgg</span></code> backends require a framework build to function
correctly. This can result in issues for a Python installation not build as a
framework and may also happen in virtual envs and when using (Ana)conda. From
Matplotlib 1.5 onwards, both backends check that a framework build is available
and fail if a non framework build is found. (Without this check a partially
functional figure is created. In particular, it is produced in the background
and cannot be put in front of any other window.)</p>
<divclass="section" id="virtualenv">
<h3>virtualenv<aclass="headerlink" href="#virtualenv" title="Permalink to this headline">¶</a></h3>
<p>In a <aclass="reference external" href="https://virtualenv.pypa.io/">virtualenv</a>, a non-framework build is used even when the environment is
created from a framework build (<aclass="reference external" href="https://github.com/pypa/virtualenv/issues/54">virtualenv bug #54</a>, <aclass="reference external" href="https://github.com/pypa/virtualenv/issues/609">virtualenv bug #609</a>).</p>
<p>The solution is to not use virtualenv, but instead the stdlib's <aclass="reference external" href="https://docs.python.org/3/library/venv.html">venv</a>, which
provides similar functionality but without exhibiting this issue.</p>
<p>If you absolutely need to use virtualenv rather than venv, then from within
the environment you can set the <codeclass="docutils literal notranslate"><spanclass="pre">PYTHONHOME</span></code> environment variable to
<codeclass="docutils literal notranslate"><spanclass="pre">$VIRTUAL_ENV</span></code>, then invoke Python using the full path to the framework build
<h3>conda<aclass="headerlink" href="#conda" title="Permalink to this headline">¶</a></h3>
<p>The default python provided in (Ana)conda is not a framework build. However,
a framework build can easily be installed, both in the main environment and
in conda envs: install python.app (<codeclass="docutils literal notranslate"><spanclass="pre">conda</span><spanclass="pre">install</span><spanclass="pre">python.app</span></code>) and use
<codeclass="docutils literal notranslate"><spanclass="pre">pythonw</span></code> rather than <codeclass="docutils literal notranslate"><spanclass="pre">python</span></code></p>