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

15,087

Solution 1

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.

Solution 2

Try this:

pip install numpy --upgrade

It works for me

Share:
15,087
crash springfield
Author by

crash springfield

Updated on June 12, 2022

Comments

  • crash springfield
    crash springfield almost 2 years

    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.