Cannot import matplotlib with ipython/jupyter notebook
<p>Cannot import matplotlib with ipython/jupyter notebook through a virtual environment.</p>

<p>I'm able to import matplotlib just fine using the console. Having seen other SO posts I can't seem to get this set up right.</p>

<p>I followed <a href="http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs" rel="nofollow">this</a> to get the separate ipython/jupyter kernel.</p>

<p>When I checked my locations through jupyter I get </p>

<p><code>six.__file__</code>: <code>'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc'</code> </p>

<p>and </p>

<p><code>datutil.__file__</code>: <code>'/Library/Python/2.7/site-packages/dateutil/__init__.pyc'</code></p>

<p>I am not sure these are correct. Main jupyter error below</p>

<pre><code>---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
&lt;ipython-input-3-20188fbdb2fd&gt; in &lt;module&gt;()
      1 
----&gt; 2 import matplotlib.pyplot as plt
      3 get_ipython().magic(u'matplotlib inline')

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py in &lt;module&gt;()
     27 from matplotlib import docstring
     28 from matplotlib.backend_bases import FigureCanvasBase
---&gt; 29 from matplotlib.figure import Figure, figaspect
     30 from matplotlib.gridspec import GridSpec
     31 from matplotlib.image import imread as _imread

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/figure.py in &lt;module&gt;()
     34 import matplotlib.colorbar as cbar
     35 
---&gt; 36 from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
     37 from matplotlib.blocking_input import BlockingMouseInput, BlockingKeyMouseInput
     38 from matplotlib.legend import Legend

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py in &lt;module&gt;()
     18 import matplotlib.colors as mcolors
     19 import matplotlib.contour as mcontour
---&gt; 20 import matplotlib.dates as _  # &lt;-registers a date unit converter
     21 from matplotlib import docstring
     22 import matplotlib.font_manager as font_manager

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/dates.py in &lt;module&gt;()
    117 
    118 
--&gt; 119 from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
    120                             MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY,
    121                             SECONDLY)

/Library/Python/2.7/site-packages/dateutil/rrule.py in &lt;module&gt;()
     17 
     18 from six import advance_iterator, integer_types
---&gt; 19 from six.moves import _thread
     20 import heapq
     21 

ImportError: cannot import name _thread
</code></pre>

<p>Ok I fixed this by using the tutorial properly (<a href="http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs" rel="nofollow">http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs</a>)</p>

<p>You need to set up a virtualenv, then make sure that you install jupyter within it. I was using the globally installed jupyter.</p>

<p>Then set up the new jupyter kernel (linked above) and everything should work with your virtualenv pointed to correctly</p>

python python-2.7 matplotlib virtualenv jupyter