Supporting matplotlib for both python 2 and python 3 on Mac OS X
<p>We're building code that we want to run on both Python 2 &amp; 3. It uses matplotlib. My local machine runs OS X Yosemite. </p>

<p>The <a href="http://matplotlib.org/faq/installing_faq.html#os-x-notes" rel="nofollow">matplotlib installation documentation</a> provides instructions for both python 2 &amp; 3, but implies that both cannot be supported on a single Mac. Is this true, and if not how can both be supported with matplotlib?</p>

<p>(Parenthetically, I know that separate installations can be made with virtual environments or machines. However, I've found these cumbersome on Macs. On the other hand, I'm also testing builds on a commercial cloud-based build tester that uses separate VMs for each configuration, which works reasonably well.)</p>

<p>I too find virtualenvs annoying for this sort of thing, and have run into strange issues on OSX virutalenvs with matplotlib in particular.
But there is a really nice tool for supporting parallel installations of different package &amp; python versions: <code>conda</code>. It will manage parallel environments with any Python version; for your case you can do the following:</p>

<ol>
<li><p>Install <a href="http://conda.pydata.org/miniconda.html" rel="nofollow">miniconda</a></p></li>
<li><p>Create a Python 3 environment: <code>conda create -n py3env python=3.5 matplotlib</code></p></li>
<li><p>Create a Python 2 environment: <code>conda create -n py2env python=2.7 matplotlib</code></p></li>
<li><p>Activate the one you want with, e.g. <code>source activate py2env</code></p></li>
</ol>

<p>And you're ready to go. For more information on conda environments, see the <a href="http://conda.pydata.org/docs/using/envs.html" rel="nofollow">conda-env docs</a>.</p>

python osx matplotlib