I'm trying to install faiss-cpu via pip (pip install faiss-cpu) and get the following error:
× Building wheel for faiss-cpu (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
running bdist_wheel
running build
running build_py
running build_ext
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 -module swigfaiss -o faiss/faiss/python/swigfaiss_wrap.cpp faiss/faiss/python/swigfaiss.i
Traceback (most recent call last):
File "/Users/me/langchain/venv/bin/swig", line 5, in <module>
from swig import swig
ModuleNotFoundError: No module named 'swig'
error: command '/Users/me/langchain/venv/bin/swig' failed with exit code 1
[end of output]
I've searched around and tried various solutions but nothing has worked.
I have the following setup:
Python 3.12.1
pip 23.3.2
SWIG Version 4.1.1
Python swig package (via pip): 4.1.1.post1
faiss-cpuis not available inpython-3.12. According to their page on pypi it's available frompython-3.7topython-3.11. You need to downgrade your python in order to installfaiss-cpuin your system. Now you can either removepython-3.12and installpython-3.10on your system. Or use conda to create a virtual env withpython-3.10like following:then to activate:
now install
faiss-cpu: