Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version errors for numpy when importing matplotlib

When I

import matplotlib

I get no errors, but when I

import matplotlib.pyplot

I get

RuntimeError: module compiled against API version 8 but this version of numpy is 7
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/matplotlib/pyplot.py", line 24, in <module>
    import matplotlib.colorbar
  File "/Library/Python/2.7/site-packages/matplotlib/colorbar.py", line 27, in <module>
    import matplotlib.artist as martist
  File "/Library/Python/2.7/site-packages/matplotlib/artist.py", line 8, in <module>
    from transforms import Bbox, IdentityTransform, TransformedBbox, \
  File "/Library/Python/2.7/site-packages/matplotlib/transforms.py", line 35, in <module>
    from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import

This looks like a version error; but yolk says I have an up-to-date version, and pip says everything is up-to-date and won't help "really" update things.

What can I do to make sure that the necessary packages are "really" up-to-date to avoid this error; what packages need to be "really" updated (matplotlib; numpy; others?).


Uninstalling and re-istalling numpy (using pip) does not help.

Did pip somehow let me recently update matplotlib to "too new" a version, wile the pip version of numpy lags?


My sys.path is:

['',
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',  
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',  
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',  
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',  
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',  
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',  
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',  
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',  
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', 
'/Library/Python/2.7/site-packages']

and the Scypi stack is installed in site-packages where it is maintained by pip. OS X 10.9, Apple Python 2.7.5, all packages versions are those found by pip in PiPy.

like image 486
orome Avatar asked Oct 27 '13 13:10

orome


2 Answers

Forcing reinstall works in this case, as it will often do in similar cases:

sudo pip install -U --force-reinstall scipy
like image 158
orome Avatar answered Sep 28 '22 03:09

orome


I had this same error as well. I was able fix it by installing numpy through my python IDE. I am using PyCharm. When Pycharm opens there is an option to configure things and from there you can select python interpreters. On the righthand side a panel should appear with two options; paths and packages. select packages, then select install, and a list of available packages will pop up. Select numpy from the list and click install from this window. this fixed my error.

like image 32
Curtis Green Avatar answered Sep 28 '22 05:09

Curtis Green