Skip to content
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 2.0 breaks import #42

Closed
williamjameshandley opened this issue Sep 3, 2024 · 4 comments
Closed

numpy 2.0 breaks import #42

williamjameshandley opened this issue Sep 3, 2024 · 4 comments

Comments

@williamjameshandley
Copy link

pip installing in a fresh environment no longer works, I believe due to the numpy 2.0 upgrade.

After

python -m venv venv
source venv/bin/activate
pip install fastkde

I cannot import fastkde

$ python -c 'import fastkde'

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<string>", line 1, in <module>
  File "/tmp/fastkde/venv/lib/python3.12/site-packages/fastkde/__init__.py", line 10, in <module>
    import fastkde.fastKDE
  File "/tmp/fastkde/venv/lib/python3.12/site-packages/fastkde/fastKDE.py", line 5, in <module>
    import fastkde.empiricalCharacteristicFunction as ecf
  File "/tmp/fastkde/venv/lib/python3.12/site-packages/fastkde/empiricalCharacteristicFunction.py", line 3, in <module>
    import fastkde.nufft as nufft
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/fastkde/venv/lib/python3.12/site-packages/fastkde/__init__.py", line 10, in <module>
    import fastkde.fastKDE
  File "/tmp/fastkde/venv/lib/python3.12/site-packages/fastkde/fastKDE.py", line 5, in <module>
    import fastkde.empiricalCharacteristicFunction as ecf
  File "/tmp/fastkde/venv/lib/python3.12/site-packages/fastkde/empiricalCharacteristicFunction.py", line 3, in <module>
    import fastkde.nufft as nufft
  File "nufft.pyx", line 1, in init fastkde.nufft
ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it).

This is preventing our upgrade to numpy 2.0.

How difficult would it be to upgrade fastkde to numpy 2.0? Otherwise we may need to drop support in anesthetic

@taobrienlbl
Copy link
Collaborator

Hi @williamjameshandley, thanks for reporting this and for showing how you're using fastKDE (very cool)! Good question. I'm not certain yet, but it seems like the switch is inevitable.

I've got an un-merged commit that restricts numpy to <2.0 (453625c); would that work as a temporary fix for you in this case?

@AdamOrmondroyd
Copy link
Contributor

That sounds like a sensible temporary fix; we added a temporary numpy <2.0 restriction to anesthetic while pytables and yourselves caught up, but we would like to remove this restriction asap.

@taobrienlbl
Copy link
Collaborator

@AdamOrmondroyd and @williamjameshandley - I believe this should now be fixed in v2.1.3 which is available in pypi. Does this fix the problem for your package?

@williamjameshandley
Copy link
Author

Looks like it following this merge #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants