<p dir="auto">matplotlib v2.0.0rc1, Python 3.5,   OSX</p>
<p dir="auto">upgraded via conda over standard anaconda installation</p>
<p dir="auto"><code class="notranslate">%matplotlib notebook</code></p>
<p dir="auto">fails with an error message:</p>
<p dir="auto"><code class="notranslate">Incompatible library version: _png.cpython-35m-darwin.so requires version 43.0.0 or later, but libpng16.16.dylib provides version 39.0.0</code></p>
<p dir="auto">Resolved via: <code class="notranslate">conda upgrade libpng</code></p>
<p dir="auto">Stackoverflow suggests its an occasional issue - the last answer <a href="http://stackoverflow.com/questions/28124359/error-with-homebrew-opencv-libpng" rel="nofollow">here</a> links it to anaconda</p>
<p dir="auto">May or may not be a matplotlib installer concern</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">Matplotlib segfaults when creating a figure when used in combination with the standard multiprocessing library.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import multiprocessing as mp
import matplotlib.pyplot as plt


def plot():
    fig = plt.figure()


def main(nprocs=2):
    worker = mp.Process(target=plot)

    worker.start()

    worker.join()
    if worker.exitcode &lt; 0:
        print(&quot;Error: %s exited with error code %i.&quot; % (worker.__str__(), worker.exitcode))


if __name__ == &quot;__main__&quot;:
    main()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">multiprocessing</span> <span class="pl-k">as</span> <span class="pl-s1">mp</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>


<span class="pl-k">def</span> <span class="pl-en">plot</span>():
    <span class="pl-s1">fig</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()


<span class="pl-k">def</span> <span class="pl-en">main</span>(<span class="pl-s1">nprocs</span><span class="pl-c1">=</span><span class="pl-c1">2</span>):
    <span class="pl-s1">worker</span> <span class="pl-c1">=</span> <span class="pl-s1">mp</span>.<span class="pl-v">Process</span>(<span class="pl-s1">target</span><span class="pl-c1">=</span><span class="pl-s1">plot</span>)

    <span class="pl-s1">worker</span>.<span class="pl-en">start</span>()

    <span class="pl-s1">worker</span>.<span class="pl-en">join</span>()
    <span class="pl-k">if</span> <span class="pl-s1">worker</span>.<span class="pl-s1">exitcode</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">0</span>:
        <span class="pl-en">print</span>(<span class="pl-s">"Error: %s exited with error code %i."</span> <span class="pl-c1">%</span> (<span class="pl-s1">worker</span>.<span class="pl-en">__str__</span>(), <span class="pl-s1">worker</span>.<span class="pl-s1">exitcode</span>))


<span class="pl-k">if</span> <span class="pl-s1">__name__</span> <span class="pl-c1">==</span> <span class="pl-s">"__main__"</span>:
    <span class="pl-en">main</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto">All processes exit with code -11, <code class="notranslate">SYSSEGV</code></p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">I've figured out that creating a figure like this isn't expected to work with the GUI backend on. Putting:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib
matplotlib.use('agg')"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>
<span class="pl-s1">matplotlib</span>.<span class="pl-en">use</span>(<span class="pl-s">'agg'</span>)</pre></div>
<p dir="auto">before the other imports fixes the issue. It's understandable that you can't create multiple instances of the GUI on different processes, however it seems to me an exception should be thrown rather than a segfault.</p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating System: macOS 10.12.5</li>
<li>Matplotlib Version: 2.0.2</li>
<li>Python Version: 2.7.13, 3.6.1</li>
<li>Other Libraries: multiprocessing</li>
</ul>
<p dir="auto">Matplotlib was installed from Conda, on the <code class="notranslate">conda-forge</code> stream.</p>