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
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
Check the path
import numpy print numpy.__path__
and manually delete it using rm
I also had the same problem until I came across this Issue on Pytorch github repository. This command worked perfectly for me:
pip install numpy -I
It is also mentioned there that
pip install numpy --upgrade is not working(don’t know why). You can check the above mentioned link.
The answer is probably simple.
It worked fine for me.
I had a similar problem with numpy when running torch. I tried uninstalling numpy and installing it using -U but it didn’t work. After some search, I found this link and it solved my problem. It says you should change your numpy version.
pip uninstall numpy pip install numpy==1.19.3
Installing the previous version of NumPy, 1.19.3 should fix this. python -m pip install numpy==1.19.3
My problem is solved using the old version of numpy. The solution is to use numpy 1.19.3.
pip install numpy==1.19.3