cultionet icon indicating copy to clipboard operation
cultionet copied to clipboard

[bug] Possible binary incompatibility numpy==1.21.0

Open MatthewPierson90 opened this issue 2 years ago • 6 comments

I get the following error running "cultionet create", updating Numpy fixes the error, but I am not sure if that update causes my other issues.

Traceback (most recent call last): File "/home/matthew/.pyenv/versions/cultionet2/bin/cultionet", line 5, in from cultionet.scripts.cultionet import main File "/home/matthew/.pyenv/versions/3.8.12/envs/cultionet2/lib/python3.8/site-packages/cultionet/scripts/cultionet.py", line 13, in from cultionet.data.create import create_dataset File "/home/matthew/.pyenv/versions/3.8.12/envs/cultionet2/lib/python3.8/site-packages/cultionet/data/create.py", line 11, in import geowombat as gw File "/home/matthew/.pyenv/versions/3.8.12/envs/cultionet2/lib/python3.8/site-packages/geowombat/init.py", line 2, in from .core.api import open File "/home/matthew/.pyenv/versions/3.8.12/envs/cultionet2/lib/python3.8/site-packages/geowombat/core/init.py", line 1, in from ..backends import transform_crs File "/home/matthew/.pyenv/versions/3.8.12/envs/cultionet2/lib/python3.8/site-packages/geowombat/backends/init.py", line 2, in from .xarray_ import concat, mosaic File "/home/matthew/.pyenv/versions/3.8.12/envs/cultionet2/lib/python3.8/site-packages/geowombat/backends/xarray_.py", line 7, in from ..core.windows import get_window_offsets File "/home/matthew/.pyenv/versions/3.8.12/envs/cultionet2/lib/python3.8/site-packages/geowombat/core/windows.py", line 1, in from .util import n_rows_cols File "/home/matthew/.pyenv/versions/3.8.12/envs/cultionet2/lib/python3.8/site-packages/geowombat/core/util.py", line 9, in from ..moving import moving_window File "/home/matthew/.pyenv/versions/3.8.12/envs/cultionet2/lib/python3.8/site-packages/geowombat/moving/init.py", line 1, in from ._moving import moving_window File "geowombat/moving/_moving.pyx", line 1, in init geowombat.moving._moving ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

MatthewPierson90 avatar May 20 '22 13:05 MatthewPierson90

This looks like geowombat and cultionet were compiled with different numpy versions. Since cultionet is pinned to numpy==1.21.0, you can try:

pyenv activate your.venv
(your.venv) pip uninstall geowombat -y
(your.venv) cd cultionet/ 
# Re-install cultionet, which will install geowombat and should use numpy==1.21.0 since it's already installed
(your.venv) pip install .

My guess is that geowombat was installed first and used the most recent version of numpy.

jgrss avatar Jun 02 '22 12:06 jgrss

If that works for you, I can modify the install instructions to first install numpy. As a reference, the most up-to-date install steps can be found in the CircleCI config file.

jgrss avatar Jun 02 '22 13:06 jgrss

That would make sense! Why does cultionet need GDAL 3.2.1? (I am guessing that is part of why I need an earlier version of geowombat, when I install gdal 3.2.1 geowombat 1.7.4 gets mad, but cultionet is mad if I have gdal 3.3.2) I've been running cultionet with GDAL 3.3.2 without much issue, but that might have been the cause of some of the other problems that I had

MatthewPierson90 avatar Jun 02 '22 16:06 MatthewPierson90

I still needed up update numpy with the fresh install, with geowombat 1.8.5 I also ran into an error with a cython compiled file:

File "src/geowombat/moving/_moving.pyx", line 1, in init geowombat.moving._moving ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use 'numpy._import_array' to disable if you are certain you don't need it).

I added np._import_array to the file suggested, and it works after reinstalling geowombat

MatthewPierson90 avatar Jun 02 '22 17:06 MatthewPierson90

I think I see what is going on with GDAL, geowombat wants the version of GDAL for whatever version the GDAL binaries are, and in my case that is 3.3.2.

MatthewPierson90 avatar Jun 02 '22 17:06 MatthewPierson90

Ah, yes, your Python GDAL version should match your GDAL binaries version.

jgrss avatar Jun 05 '22 15:06 jgrss