Incompatible with NumPy 2
simonw opened this issue · comments
Simon Willison commented
Describe the bug
NumPy 2.0 was released recently, and breaks backwards compatibility with NumPy 1.0 in ways that affect these wheels.
To Reproduce
In a fresh Python virtual environment running at least Python 3.9 (3.8 and 3.7 will not recreate this bug because NumPy 2 doesn't support them, so 1.0 will be pulled in automatically).
pip install faiss-cpu
python
>>> import faiss
Expected behavior
The import should work. Instead I get this:
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.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 "<stdin>", line 1, in <module>
File "/Users/simon/.local/share/virtualenvs/ff-McyYu-N_/lib/python3.10/site-packages/faiss/__init__.py", line 16, in <module>
from .loader import *
File "/Users/simon/.local/share/virtualenvs/ff-McyYu-N_/lib/python3.10/site-packages/faiss/loader.py", line 98, in <module>
from .swigfaiss import *
File "/Users/simon/.local/share/virtualenvs/ff-McyYu-N_/lib/python3.10/site-packages/faiss/swigfaiss.py", line 10, in <module>
from . import _swigfaiss
AttributeError: _ARRAY_API not found
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/simon/.local/share/virtualenvs/ff-McyYu-N_/lib/python3.10/site-packages/faiss/__init__.py", line 16, in <module>
from .loader import *
File "/Users/simon/.local/share/virtualenvs/ff-McyYu-N_/lib/python3.10/site-packages/faiss/loader.py", line 98, in <module>
from .swigfaiss import *
File "/Users/simon/.local/share/virtualenvs/ff-McyYu-N_/lib/python3.10/site-packages/faiss/swigfaiss.py", line 10, in <module>
from . import _swigfaiss
ImportError: numpy.core.multiarray failed to import
Desktop (please complete the following information):
- OS: macOS Sonoma 14.1.1 (23B81)
- Architecture: arm64
- Python: 3.10.10
- Version: latest wheel
Kota Yamaguchi commented
Perhaps the quick workaround is to pin requirements to numpy<2.0
.
Simon Willison commented
Perhaps the quick workaround is to pin requirements to
numpy<2.0
.
Submitted a PR for that here: