Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm new to ipython notebook, but I have the following error message whenever I run import matplotlib.pyplot as plt. I'm using Mac. It works fine with the built-in python or Canopy. The problem only exists with ipython notebook. I also tried to update the numpy, but the problem still exists. Would be grateful for someone to help!

import matplotlib.pyplot as plt

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 9 but this version of numpy is 7

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-6f467123fe04> in <module>()
----> 1 import matplotlib.pyplot

/Users/Michael/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
     22 
     23 import matplotlib
---> 24 import matplotlib.colorbar
     25 from matplotlib import _pylab_helpers, interactive
     26 from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike

/Users/Michael/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/colorbar.py in <module>()
     27 import matplotlib.artist as martist
     28 import matplotlib.cbook as cbook
---> 29 import matplotlib.collections as collections
     30 import matplotlib.colors as colors
     31 import matplotlib.contour as contour

/Users/Michael/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/collections.py in <module>()
     21 import matplotlib.artist as artist
     22 from matplotlib.artist import allow_rasterization
---> 23 import matplotlib.backend_bases as backend_bases
     24 import matplotlib.path as mpath
     25 from matplotlib import _path

/Users/Michael/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/backend_bases.py in <module>()
     48 
     49 import matplotlib.tight_bbox as tight_bbox
---> 50 import matplotlib.textpath as textpath
     51 from matplotlib.path import Path
     52 from matplotlib.cbook import mplDeprecation

/Users/Michael/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/textpath.py in <module>()
      9 from matplotlib.path import Path
     10 from matplotlib import rcParams
---> 11 import matplotlib.font_manager as font_manager
     12 from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
     13 from matplotlib.ft2font import LOAD_TARGET_LIGHT

/Users/Michael/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/font_manager.py in <module>()
     51 import matplotlib
     52 from matplotlib import afm
---> 53 from matplotlib import ft2font
     54 from matplotlib import rcParams, get_cachedir
     55 from matplotlib.cbook import is_string_like

ImportError: numpy.core.multiarray failed to import
share|improve this question
 
Try running ipython notebook --pylab –  askewchan yesterday
 
Hi, thanks for help. I tried by got the error message below. I tried to install matplotlib again, and ran the program again, but still got the same error message in ipython notebook. 'WARNING: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv. --------------------------------------------------------------------------- None Traceback (most recent call last) None: None [IPKernelApp] WARNING | Eventloop or matplotlib integration failed. Is matplotlib installed?' –  user3084957 yesterday
1  
it looks like your installation is borked. Look like you are on a mac which seems to have endemic problems with getting the paths correct. How did you install matplotlib/enthought? –  tcaswell yesterday
 
I installed it through enthought.com/downloads. I have just redownloaded and reinstalled the package but it still doesn't work. Indeed, I install ipython through Anaconda instead of Enthought Canopy because there is an error message "You are running enpkg as a root user inside a virtual environment. Please run it as a normal user" when I followed the installation instructions for Indeed, I install ipython through Anaconda instead of Enthought at ipython.org/install.html –  user3084957 9 hours ago
add comment

1 Answer

How committed are you to Canopy? I had a few configuration issues attempting to use Canopy and ended up using Homebrew to customize my own Python install instead. There's a really helpful guide at:

http://joernhees.de/blog/2013/06/08/mac-os-x-10-8-scientific-python-with-homebrew/

I followed all of those steps except for two or three (don't remember which exactly) the "brew install" method didn't work and I had to pip the module instead.

I just opened up an IPython notebook to verify that everything works fine on my distribution.

from matplotlib import pyplot as plt
import numpy as np

x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()

The above gives me the expected output.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.