`import rasterio` error on Win7 and Mac: ValueError: numpy.dtype has the wrong size, try recompiling


nurbachris@...
 

I am having the same problem on Windows 7 and Mac OS X High Sierra:

1) Windows 7 (64 bits)

Using python 2.7 (32 bits).

I have installed GDAL Core and its Python bindings using the executables here (resp. gdal-202-1500-core.msi and GDAL-2.2.3.win32-py2.7.msi). This worked well and I could successfully use gdal in python scripts.

Then I tried to install rasterio using rasterio‑1.0.3‑cp27‑cp27m‑win32.whl:
py -2.7 -m pip install rasterio‑1.0.3‑cp27‑cp27m‑win32.whl

This went through successfully.

However when starting python and invoking import rasterio I get the following error message:

Traceback (most recent call last):
  File "test1.py", line 1, in <module>
    import rasterio
  File "C:\Python27\lib\site-packages\rasterio\__init__.py", line 31, in <module>
    from rasterio._base import gdal_version
  File "rasterio\_base.pyx", line 1, in init rasterio._base
  File "__init__.pxd", line 164, in init rasterio._shim
ValueError: numpy.dtype has the wrong size, try recompiling. Expected 52, got 56

2) Mac OS X High Sierra (10.13.6)

Interestingly, I am having exactly the same error on Mac OS X High Sierra after installing GDAL Complete 2.1 from here, and rasterio using:
pip2.7 install rasterio.

The installation steps are successful, but I get the same error as above when executing import rasterio in python 2.7:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/rasterio/__init__.py", line 23, in <module>
    from rasterio._base import gdal_version
  File "rasterio/_base.pyx", line 1, in init rasterio._base
  File "__init__.pxd", line 164, in init rasterio._shim
ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96

I have read posts advising to upgrade numpy, however it is installed as distutils project (on both systems) and therefore I cannot upgrade with pip. So I am not sure what is the best way forward.

Any help would be greatly appreciated.

Join main@rasterio.groups.io to automatically receive all group messages.