python-3.xwindowsswigpython-3.12

Error installing faiss-cpu with pip: swig.exe command failed during wheel build for Python 3.12.0


I'm trying to install the faiss-cpu package in my Python environment, but I'm encountering a build error related to swig.exe during the wheel building process. I'm working within a virtual environment on Windows and using Python 3.12.0.

Here's the error message I receive when I run pip install faiss-cpu:

error: subprocess-exited-with-error

× Building wheel for faiss-cpu (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [details of the error]
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
error: command 'swig.exe' failed: None

enter image description here

Note: I have noticed a notification about a newer version of pip being available. Not sure if that's part of the issue.

To troubleshoot, I've attempted the following:

  1. Ensured that swig is installed and the path to swig.exe is in my system's PATH environment variable. Running swig -version in the command prompt returns the version correctly.
  2. I haven't yet updated pip and setuptools to the latest versions, but I noticed the notification about the new pip version (23.3.2).
  3. I have not checked if Visual C++ Build Tools are required and properly installed for this package.

I expected the package to install without any issues as I followed the standard pip installation procedure. I'm wondering if the issue is specific to my Python version (3.12.0) or some other configuration on my system.


Solution

  • I got a similar error on my mac when I tried to install the faiss-cpu 1.11.0. Then it worked when I installed 1.10.0 version instead (pip install faiss-cpu==1.10.0)