Search code examples
macosnumpymatplotlibpackageosx-mavericks

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 PyPi repository.


Solution

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

    sudo pip install -U --force-reinstall scipy