安装 faiss-cpu 时出错 - 没有名为“swig”的模块

问题描述 投票:0回答:1

我尝试通过 pip (

pip install faiss-cpu
) 安装 faiss-cpu 并收到以下错误:

  × 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]

我四处寻找并尝试了各种解决方案,但没有任何效果。

我有以下设置:

Python 3.12.1
pip 23.3.2
SWIG Version 4.1.1
Python swig package (via pip): 4.1.1.post1
python pip swig langchain faiss
1个回答
0
投票

faiss-cpu
python-3.12
中不可用。根据 他们在 pypi 上的页面,它可以在
python-3.17
python-3.11
之间使用。您需要降级您的 python 才能在系统中安装
faiss-cpu
。现在您可以在系统上删除
python-3.12
并安装
python-3.10
。或者使用 conda 创建一个带有
python-3.10
的虚拟环境,如下所示:

conda create -n myenv python=3.10

然后激活:

conda activate myenv

现在安装

faiss-cpu
:

pip install faiss-cpu
© www.soinside.com 2019 - 2024. All rights reserved.