Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9

I'm going through the API tutorial on New Coder (this one) and got the following error when I try to run the program:

RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9Traceback (most recent call last):
  File "api.py", line 7, in <module>
import matplotlib.pyplot as plt
  File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
  File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
  File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
  File "/home/crash/TestEnv/venv/local/lib/python2.7/site-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import

I know it isn't my code because I tried running it with the example code too and had the same issue. One answer I saw suggested on here was to try Numpy 1.8, but that didn't work either.

Also, all of this is set up within a virtual environment as directed so I don't think it's an issue of what I have installed elsewhere.

like image 600
crash springfield Avatar asked May 29 '16 21:05

crash springfield


People also ask

How do I find out what version of Numpy I have?

Type python -m pip show and press 'Enter'. The result will show the package version and other information about the package.

How do I check Numpy version in Anaconda prompt?

You can use the pip show command to know the version of the numpy array. Copy and paste the command below to output the version number. Using this command you will get all the details about the python package like, Name,version, author ,summary ,location e.t.c which is very useful.


2 Answers

Installing packets from file with requirements may cause failures. I mean something like pip install -r requirements.txt

It seems to me that pip just installs packets in order without dependencies (first line from file, second line, ...).

I had same issue because of having installed numpy outside of environment and numpy after matplotlib in requirements.txt Pip compiled matplotlib with system nympy, after that it installed new numpy and nothing worked.

I just have switched strings and set matplotlib after numpy. Now it works.

like image 161
ckorzhik Avatar answered Oct 08 '22 18:10

ckorzhik


Try this:

pip install numpy --upgrade

It works for me

like image 34
Luna Kong Avatar answered Oct 08 '22 19:10

Luna Kong