haystack icon indicating copy to clipboard operation
haystack copied to clipboard

Haystack FAISS does not support Python 3.11

Open GalenReich opened this issue 2 years ago • 2 comments

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

System:

  • OS: Dockerized python:3.11 running on Windows 10
  • Haystack version (commit or version number): Reproduced with 1.16.1 and 1.20

GalenReich avatar Sep 08 '23 16:09 GalenReich

Any success installing on python 3.11.*? @GalenReich

Tottowich avatar Oct 30 '23 09:10 Tottowich

Afraid not, downgrading to Python 3.10 was an option for me. But wanted to document this in case others hit the same issue.

GalenReich avatar Oct 30 '23 09:10 GalenReich