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

408 views Asked by At

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.

1

There are 1 answers

0
Ben On

In the current latest faiss-cpu package, 1.7.4, they specify up to python 3.11 -- it worked for me when downgraded to that version. https://pypi.org/project/faiss-cpu/1.7.4/