Unidata / netcdf4-python

netcdf4-python: python/numpy interface to the netCDF C library
http://unidata.github.io/netcdf4-python
MIT License
752 stars 263 forks source link

Numpy binary incompatibility warning #1354

Open hassec opened 2 months ago

hassec commented 2 months ago

To create a minimal reproducer (I used Python 3.11.9):

python -m venv test_nc4
source test_nc4/bin/activate
pip install netcdf4
python -c "import numpy;import warnings;warnings.filterwarnings('error');import netCDF4"

This will raise an error with: numpy.ndarray size changed, may indicate binary incompatibility. Expected 16 from C header, got 96 from PyObject

This isn't numpy 2.0 specific, pip install netcdf4 "numpy<2.0" will raise the same warning.

To the best of my understanding this means that the numpy that was used during the netcdf4 build is incompatible with the numpy version I'm using.

I know that this is usually just a warning, but this means I've got to manually ignore these in my pytest suite.

It's also hard to gauge for a user whether this warning is problematic. Thus I'm wondering if this can be fixed on the netcdf4 side?