I am trying to install faiss-cpu on my Windows | Streamlit where getting following error and looking for any idea how to resolve this. Appreciate your kind support.
Building wheel for faiss-cpu (pyproject.toml) … error
× Building wheel for faiss-cpu (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [13 lines of output]
building ‘faiss._swigfaiss’ extension
swigging faiss\faiss\python\swigfaiss.i to faiss\faiss\python\swigfaiss_wrap.cpp
swig.exe -python -c++ -Doverride= -I/usr/local/include -Ifaiss -doxygen -DSWIGWIN -module swigfaiss -o faiss\faiss\python\swigfaiss_wrap.cpp faiss\faiss\python\swigfaiss.i
Traceback (most recent call last):
File “”, line 198, in _run_module_as_main
File “”, line 88, in run_code
File "E:\AI-ML-Code\GenerativeAI\GenAI_LearnLangChainLLMAppsOpenAI_Llama_2\Sec09_PDF_ChatApp_StreamlitApp\PDF_ChatApp_StreamlitApp\venv\Scripts\swig.exe_main.py", line 4
ModuleNotFoundError: No module named ‘swig’
error: command ‘E:\AI-ML-Code\GenerativeAI\GenAI_LearnLangChainLLMAppsOpenAI_Llama_2\Sec09_PDF_ChatApp_StreamlitApp\PDF_ChatApp_StreamlitApp\venv/Scripts\swig.exe’ fail
ed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for faiss-cpu
Successfully built tiktoken
Failed to build faiss-cpu
ERROR: Could not build wheels for faiss-cpu, which is required to install pyproject.toml-based projects
Can you please confirm which suggestion solved you issue? I am facing similar challenge. I already have SWIG version 4.1.1; however I am using Python 3.12.1.
Just wondering, if I need to downgrade my python to 3.11 or below?
Hello @ashishsrivastava - pls check once if the software / package you are installing has a compatibility with Python 3.12.1, else you need to create a project based on the Python compatibility version which you may see in the definition page of the package. Eg. in case of FAISS db, on the left hand side it has clearly mentioned which is the top most compatible version of supported Python that you need to have in the project.
Thanks @BikashKumar. Somehow I missed checking the dependencies earlier.
I checked again and found that faiss-cpu is supported till Python 3.11 only till now.
I switched back to Python 3.11 and it worked now.
Thanks for pointing out!
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.