错误:无法为 hnswlib 构建轮子,这是安装基于 pyproject.toml 的项目所必需的

Sil*_*er0 37 python pip pandas

我正在尝试在 mac 上安装 embeddinghub(尝试过pip3 install embeddinghub和pip3 install pandas embeddinghub protobuf),但我收到同样的错误“ could not build wheels for hnswlib, which is required to install pyproject.toml-based projects”。我找不到任何有关 hnswlib 的解决方案。我已经尝试了很多关于 PEP517 的解决方案以及为其他事情造轮子,但没有一个解决方案有帮助。这是完整的错误:

\n

错误

\n
Collecting pandas\n  Using cached pandas-1.5.0-cp310-cp310-macosx_11_0_arm64.whl (10.8 MB)\nCollecting embeddinghub\n  Using cached embeddinghub-0.0.1.post12-py3-none-any.whl\nCollecting protobuf\n  Using cached protobuf-4.21.7-cp37-abi3-macosx_10_9_universal2.whl (484 kB)\nCollecting pytz>=2020.1\n  Using cached pytz-2022.4-py2.py3-none-any.whl (500 kB)\nCollecting python-dateutil>=2.8.1\n  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)\nCollecting numpy>=1.21.0\n  Using cached numpy-1.23.3-cp310-cp310-macosx_11_0_arm64.whl (13.3 MB)\nCollecting grpcio==1.40.0\n  Using cached grpcio-1.40.0-cp310-cp310-macosx_10_10_universal2.whl\nCollecting hnswlib==0.5.2\n  Using cached hnswlib-0.5.2.tar.gz (29 kB)\n  Installing build dependencies ... done\n  Getting requirements to build wheel ... done\n  Preparing metadata (pyproject.toml) ... done\nCollecting numpy>=1.21.0\n  Using cached numpy-1.21.1-cp310-cp310-macosx_12_0_universal2.whl\nCollecting six==1.16.0\n  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)\nBuilding wheels for collected packages: hnswlib\n  Building wheel for hnswlib (pyproject.toml) ... error\n  error: subprocess-exited-with-error\n  \n  \xc3\x97 Building wheel for hnswlib (pyproject.toml) did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [17 lines of output]\n      running bdist_wheel\n      running build\n      running build_ext\n      creating var\n      creating var/folders\n      creating var/folders/3h\n      creating var/folders/3h/0w98c6q56bl4x4c2qm31np_c0000gn\n      creating var/folders/3h/0w98c6q56bl4x4c2qm31np_c0000gn/T\n      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Users/s/venv/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/3h/0w98c6q56bl4x4c2qm31np_c0000gn/T/tmp5hthbs8k.cpp -o var/folders/3h/0w98c6q56bl4x4c2qm31np_c0000gn/T/tmp5hthbs8k.o -std=c++14\n      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Users/s/venv/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/3h/0w98c6q56bl4x4c2qm31np_c0000gn/T/tmpipibvgip.cpp -o var/folders/3h/0w98c6q56bl4x4c2qm31np_c0000gn/T/tmpipibvgip.o -fvisibility=hidden\n      building 'hnswlib' extension\n      creating build\n      creating build/temp.macosx-10.9-universal2-cpython-310\n      creating build/temp.macosx-10.9-universal2-cpython-310/python_bindings\n      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/private/var/folders/3h/0w98c6q56bl4x4c2qm31np_c0000gn/T/pip-build-env-hhht57g1/overlay/lib/python3.10/site-packages/pybind11/include -I/private/var/folders/3h/0w98c6q56bl4x4c2qm31np_c0000gn/T/pip-build-env-hhht57g1/overlay/lib/python3.10/site-packages/numpy/core/include -I./hnswlib/ -I/Users/s/venv/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c ./python_bindings/bindings.cpp -o build/temp.macosx-10.9-universal2-cpython-310/./python_bindings/bindings.o -O3 -march=native -stdlib=libc++ -mmacosx-version-min=10.7 -DVERSION_INFO=\\"0.5.2\\" -std=c++14 -fvisibility=hidden\n      clang: error: the clang compiler does not support '-march=native'\n      error: command '/usr/bin/clang' failed with exit code 1\n      [end of output]\n  \n  note: This error originates from a subprocess, and is likely not a problem with pip.\n  ERROR: Failed building wheel for hnswlib\nFailed to build hnswlib\nERROR: Could not build wheels for hnswlib, which is required to install pyproject.toml-based projects\n
Run Code Online (Sandbox Code Playgroud)\n

Rob*_*Rob 49

尝试设置环境变量:

export HNSWLIB_NO_NATIVE=1  
Run Code Online (Sandbox Code Playgroud)

然后重试...

[编辑添加:这仅适用于 Mac。]

  • 这不适用于 WSL Ubuntu (3认同)
  • 这适用于 Apple MacBook Pro(2.9 GHz 四核 Intel Core i7)Ventura 13.1 (2认同)
  • 为我在 M1 Macbook Air 上工作,TY :) (2认同)

Var*_*ada 49

我在 Windows 操作系统上执行pip install chromadb==0.3.22.

为了解决这个问题,

您需要先下载https://visualstudio.microsoft.com/visual-cpp-build-tools/。

接下来,导航到“单个组件”,找到这两个

在此输入图像描述

和 Windows 10 SDK

在此输入图像描述

来源:https ://github.com/chroma-core/chroma/issues/189#issuecomment-1454418844

  • 你是怎么想出这个解决方案的?惊人的... (2认同)

小智 16

在 Ubuntu 中,这些命令解决了这个问题,也许 Mac 的替代方案也很有用:

sudo apt install python3-dev
sudo apt-get install build-essential -y
Run Code Online (Sandbox Code Playgroud)

  • 修复了 Ubuntu 22.04 中的问题 (2认同)

小智 6

对于 Ubuntu 20 及更高版本,安装开发工具并为您正在使用的 Python 版本构建必需品:

对于Python3.10:

sudo apt install python3.10-dev && sudo apt-get install build-essential -y
Run Code Online (Sandbox Code Playgroud)

对于Python3.11:

sudo apt install python3.11-dev && sudo apt-get install build-essential -y
Run Code Online (Sandbox Code Playgroud)


小智 1

clang: error: the clang compiler does not support '-march=native'

error: command '/usr/bin/clang' failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

看来问题是由 clang 编译器引起的,它-march=native以前不支持该标志。

以下提交添加了对该标志的支持,您可能需要为其安装最新的 Xcode。

https://github.com/llvm/llvm-project/commit/fcca10c69aaab539962d10fcc59a5f074b73b0de