title: matplotlib not working in import
body: <blockquote>
    <p><a href="https://stackoverflow.com/questions/35236953/attributeerror-module-object-has-no-attribute-cbook">AttributeError: &#39;module&#39; object has no attribute &#39;cbook&#39;</a> does not answer my question.</p>
  </blockquote>
  
  <p><code>import matplotlib.pyplot as plt</code> is not working. Error is attached in the image.</p>
  
  <p>When, I run <code>pip install matplotlib</code> - it shows as already installed. Please see log below:</p>
  
  <p><code>
  Requirement already satisfied (use --upgrade to upgrade): matplotlib in ./anaconda/lib/python2.7/site-packages
  Requirement already satisfied (use --upgrade to upgrade): numpy&gt;=1.6 in ./anaconda/lib/python2.7/site-packages (from matplotlib)
  Requirement already satisfied (use --upgrade to upgrade): python-dateutil in ./anaconda/lib/python2.7/site-packages (from matplotlib)
  Requirement already satisfied (use --upgrade to upgrade): pytz in ./anaconda/lib/python2.7/site-packages (from matplotlib)
  Requirement already satisfied (use --upgrade to upgrade): cycler in ./anaconda/lib/python2.7/site-packages (from matplotlib)
  Requirement already satisfied (use --upgrade to upgrade): pyparsing!=2.0.4,&gt;=1.5.6 in ./anaconda/lib/python2.7/site-packages (from matplotlib)
  Requirement already satisfied (use --upgrade to upgrade): six&gt;=1.5 in ./anaconda/lib/python2.7/site-packages (from python-dateutil-&gt;matplotlib)
  </code></p>
  
  <p><a href="https://i.stack.imgur.com/zkajf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zkajf.png" alt=""></a></p>
  
  <p><strong>Update 1</strong>
  As per a suggestion in comments, tried importing the same in terminal. Following is the output</p>
  
  <pre><code>&gt;&gt;&gt; import matplotlib.pyplot as plt
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/Users/prabodhprakash/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in &lt;module&gt;
      from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
    File "/Users/prabodhprakash/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py", line 33, in &lt;module&gt;
      import numpy as np
    File "/Users/prabodhprakash/anaconda/lib/python2.7/site-packages/numpy/__init__.py", line 112, in &lt;module&gt;
      from ._globals import ModuleDeprecationWarning, VisibleDeprecationWarning
  ImportError: No module named _globals
  </code></pre>
  
  <p><strong>Update 2</strong>
  After running few more commands, as suggested in comments, I now get this error:</p>
  
  <pre><code>---------------------------------------------------------------------------
  RuntimeError                              Traceback (most recent call last)
  &lt;ipython-input-10-385145dcc870&gt; in &lt;module&gt;()
  ----&gt; 1 import matplotlib.pyplot as plt
        2 get_ipython().magic(u'matplotlib inline')
  
  /Users/prabodhprakash/anaconda/envs/gl-env/lib/python2.7/site-packages/matplotlib/pyplot.py in &lt;module&gt;()
      113 
      114 from matplotlib.backends import pylab_setup
  --&gt; 115 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
      116 
      117 _IP_REGISTERED = None
  
  /Users/prabodhprakash/anaconda/envs/gl-env/lib/python2.7/site-packages/matplotlib/backends/__init__.pyc in pylab_setup()
       30     # imports. 0 means only perform absolute imports.
       31     backend_mod = __import__(backend_name,
  ---&gt; 32                              globals(),locals(),[backend_name],0)
       33 
       34     # Things we pull in from all backends
  
  /Users/prabodhprakash/anaconda/envs/gl-env/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py in &lt;module&gt;()
       17 
       18 import matplotlib
  ---&gt; 19 from matplotlib.backends import _macosx
       20 
       21 from .backend_agg import RendererAgg, FigureCanvasAgg
  
  RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
  </code></pre>