Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

numpy.core.multiarray failed to import

Tags:

python

numpy

I used the following command to know the numpy version I am using

pip show numpy

output shown below

---
Name: numpy
Version: 1.8.2
Location: /usr/lib/python2.7/dist-packages
Requires: 

However when I am running matplotlib, I got a error as

RuntimeError: module compiled against API version a but this version of numpy is 9
        from matplotlib import pyplot as plt
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 27, in <module>
        import matplotlib.colorbar
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 32, in <module>
        import matplotlib.artist as martist
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/artist.py", line 12, in <module>
        from .transforms import Bbox, IdentityTransform, TransformedBbox, \
      File "/usr/local/lib/python2.7/dist-packages/matplotlib/transforms.py", line 39, in <module>
        from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,

I tried to upgrade numpy,

pip install numpy --upgrade

it shows to be installed successfully, but numpy still shows to be 1.8.2 and error continues to exist when running matplotlib.

I thought to uninstall numpy and reinstall it, the system gives the message saying

Not uninstalling numpy at /usr/lib/python2.7/dist-packages, owned by OS

how to solve it ? any idea about

RuntimeError: module compiled against API version a but this version of numpy is 9

like image 484
user824624 Avatar asked Dec 02 '15 19:12

user824624


1 Answers

How can I upgrade numpy? might be working for you. IN that case it was a path problem:

RuntimeError: module compiled against API version 9 but this version of numpy is 6
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import 

Solution:

Check the path

import numpy
print numpy.__path__

and manually delete it using rm

like image 79
cattt84 Avatar answered Oct 18 '22 10:10

cattt84