crash springfield
crash springfield

Reputation: 1082

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.

Upvotes: 6

Views: 17134

Answers (2)

Luna Kong
Luna Kong

Reputation: 3155

Try this:

pip install numpy --upgrade

It works for me

Upvotes: 2

ckorzhik
ckorzhik

Reputation: 788

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.

Upvotes: 4

Related Questions