1

This question is already on StackOverflow (ImportError: numpy.core.multiarray failed to import) but no Answer helped.

I did install GDAL: GDAL-3.4.2-cp37-cp37m-win_amd64.whl and numpy: numpy-1.21.6+mkl-cp37-cp37m-win_amd64.whl from the website : https://www.lfd.uci.edu/~gohlke/pythonlibs/#_gdal

By using the command .ReadAsArray(0,0,500,500) I am getting this error:

RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd

Traceback (most recent call last):

  File "D:\adress\Codes\EdgeN2m.py", line 26, in <module>
    e = EDGE.ReadAsArray(0,0,500,500)

  File "C:\Users\name\miniconda3\lib\site-packages\osgeo\gdal.py", line 3655, in ReadAsArray
    from osgeo import gdal_array

  File "C:\Users\name\miniconda3\lib\site-packages\osgeo\gdal_array.py", line 13, in <module>
    from . import _gdal_array

ImportError: numpy.core.multiarray failed to import

  • You should be able to install everything into a `conda` environment and forget about `*.whl`. But you may have to hold back the `gdal` version, e.g. `conda create -n test_env python=3.9 gdal=3.1 numpy` . – Robert Davy Jun 20 '22 at 04:33
  • Make sure you install numpy >= 1.21.x. Your version of numpy is 1.19.x (C_API_VERSION=0xd ). – cgohlke Jun 20 '22 at 06:01

1 Answers1

1

You can install the numpy with different version to check which one can work.

For me, I install gdal-3.4.3 which is compatible with numpy-1.22.0

Hope this helps.