matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
779 stars 392 forks source link

numpy.core.multiarray failed to import #444

Closed guicostas closed 2 years ago

guicostas commented 5 years ago

RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb Traceback (most recent call last): File "brazil.py", line 3, in from mpl_toolkits.basemap import Basemap File "/usr/local/lib/python2.7/dist-packages/mpl_toolkits/basemap/init.py", line 37, in import _geoslib ImportError: numpy.core.multiarray failed to import

molinav commented 2 years ago

Could you provide some more information about your working environment? This would mean:

If you are using either Windows or GNU/Linux, I would recommend you to install basemap using pip. Since version 1.3.0 we provide precompiled binary wheels and it is as simple as doing:

python -m pip install basemap

In case you need the high-resolution auxiliary datasets, you would have to install them manually:

python -m pip install basemap-data-hires
molinav commented 2 years ago

I am closing this issue due to lack of feedback. From your traceback

RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb

this is the typical problem that occurs when you build basemap using a newer numpy version (e.g. >= 1.20) but later run it with an elder numpy version (e.g. < 1.20). There has been effort in remediating this issue by creating GitHub Actions that generate precompiled binary wheels for different platforms (in your case it looks like GNU/Linux).

I would just recommend you install the precompiled wheels from PyPI if you cannot (or do not want to) build from source. In addition, the basemap repository now contains a pyproject.toml file with the proper definition of the build dependencies, so this problem should not be appearing anymore.