Haystack FAISS does not support Python 3.11
Describe the bug
Currently, using haystack with the FAISS dependency (pip install farm-haystack[FAISS]) is incompatible with Python 3.11.
only-faiss = [
"faiss-cpu>=1.6.3,<=1.7.2",
This is because faiss-wheels (which provides faiss-cpu) only added support for Python 3.11 in 1.7.3 (Release Notes)
https://github.com/deepset-ai/haystack/pull/3603 pinned the version of faiss-cpu to 1.7.2 to solve issues with importing the documentStore.
Error message
If built using Python 3.11, I get the following opaque swig error that others have documented:
building 'faiss._swigfaiss' extension
swigging faiss/faiss/python/swigfaiss.i to faiss/faiss/python/swigfaiss_wrap.cpp
swig -python -c++ -Doverride= -I/usr/local/include -Ifaiss -doxygen -DSWIGWORDSIZE64 -o faiss/faiss/python/swigfaiss_wrap.cpp faiss/faiss/python/swigfaiss.i
Traceback (most recent call last):
File "/path_to_project/venv/bin/swig", line 5, in <module>
from swig import swig
ModuleNotFoundError: No module named 'swig'
error: command '/path_to_project/venv/bin/swig' failed with exit code 1
Downgrading to Python 3.10 solves the problem.
Expected behavior A successful installation, or an error message to indicate the incompatibility.
Additional context
https://github.com/deepset-ai/haystack/issues/4003 focuses on MacOS and unreliable pip install, the conclusion is that conda install would be preferable.
Broader compatibility issues, including issues with faiss-cpu are discussed in https://github.com/facebookresearch/faiss/issues/2410.
To Reproduce
Using Python 3.11 run:
pip install farm-haystack[FAISS]
FAQ Check
- [x] Have you had a look at our new FAQ page?
System:
- OS: Dockerized python:3.11 running on Windows 10
- Haystack version (commit or version number): Reproduced with 1.16.1 and 1.20
Any success installing on python 3.11.*? @GalenReich
Afraid not, downgrading to Python 3.10 was an option for me. But wanted to document this in case others hit the same issue.