-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Numpy binary incompatibility warning #1354
Comments
On my Windows and Linux platforms, this is not a warning but an actual ValueError
The error disappears when I downgrade to NumPy 1.26.4 Platform specifics Windows 11.0 EDIT: It appears my real issue is addressed in Issue 1338. According to the discussion, the netCDF4 version built with NumPy 2 is 1.7.0. That version PyPI is yanked! I tried to update the 1.7.1.post1, but that broke my tests! So I guess I am stuck for a little while |
I've been seeing this warning a lot -- unfortunately, I can't tell where it's coming from. I use netCDF4 a lot, but I also use all kinds of other stuff that builds against numpy, so I'm not sure it's netCDF4's fault. But I use conda-forge for everything, so in that case, something is getting built and pinned wriong in conda-forge. Which is odd, as conda forge does have numpy version pinning. But PyPi packages are more of a problem here. Hmm -- now that I think about it, I've had those working before numpy2, so ??? Anyway, maybe not useful but one more data point. |
As another data point, I only see this when installing netcdf4-python 1.6.x. Installing 1.7.x seems to all be built with numpy 2.x so backwards compatibility makes it work with numpy 1.x (I think). My unrelated problem now is that installing packages from PyPI results in not being able to use compression plugins (ex. |
@hassec what is the Python, netcdf4, and numpy versions in your vitualenv? Note that, it may be fine, regardless of the warning. @ChrisBarker-NOAA you should not see those in conda-forge. If you do, please report in the netcdf4-feedstock. @djhoese can you please open a new issue for the plugin problem? It seems unrelated to the discussions here. |
I should have noted I only had issues with PyPI packages. Letting conda install the newest compatible conda-forge packages worked as expected. |
@ocefpaf originally used python 3.11.9 and tested with the latest numpy at that time and the latest pre 2.0 and both triggered the warning. I can still reproduce it with a fresh env. Now using 3.12.6 and
|
@hassec I was able to reproduce that warning, but the test suit passed when installing that wheel locally. We did build those wheels with You can see from the logs that, for python 3.12, the numpy used was 2.1.2. 2024-10-22T17:49:10.7521563Z Collecting numpy (from netCDF4==1.7.2) Maybe something change from 2.1 to 2.2 that trigger that warning? Sill, they should be compatible. |
If warnings make your users uneasy, it will be hard for them to use any Software. BTW, numpy is the one silencing those warnings: https://github.com/numpy/numpy/blob/main/numpy/__init__.py#L320-L323 A lot of the history behind that can be read in numpy/numpy#11788 TL;DR I don't see what we can do here to solve this. It is unlikely a problem with netCDF4. Your options are:
|
I was getting those a lot in the numpy-2 transition, not so much anymore. And we have not only netCDF4, but a bunch of other code that's compiled against numpy, so I was never sure exactly what was triggering it. So: nothing to be done here -- it/when it pops up again, I'll try to take a closer look. |
Thanks, I was not aware of this. I'd argue then that the problem is actually the user code that was doing Let's close this, I agree that it doesn't seem to be a netcdf issue. |
To create a minimal reproducer (I used Python 3.11.9):
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?
The text was updated successfully, but these errors were encountered: