用Python做langflow的时候,遇到一个奇怪的问题:
Mac 英特尔芯片的本子,导入hnswlib依赖的时候报错
环境:python3
错误信息:
Building wheels for collected packages: hnswlib
Building wheel for hnswlib (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for hnswlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [17 lines of output]
running bdist_wheel
running build
running build_ext
creating var
creating var/folders
creating var/folders/cv
creating var/folders/cv/dtvck8ws72q79_jsyp4scr9h0000gn
creating var/folders/cv/dtvck8ws72q79_jsyp4scr9h0000gn/T
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -I/Users/lifengdi/WorkSpaces/PycharmProjects/langflow/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/include/python3.9 -c /var/folders/cv/dtvck8ws72q79_jsyp4scr9h0000gn/T/tmpjn2j37vr.cpp -o var/folders/cv/dtvck8ws72q79_jsyp4scr9h0000gn/T/tmpjn2j37vr.o -std=c++14
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -I/Users/lifengdi/WorkSpaces/PycharmProjects/langflow/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/include/python3.9 -c /var/folders/cv/dtvck8ws72q79_jsyp4scr9h0000gn/T/tmpvj2j9km2.cpp -o var/folders/cv/dtvck8ws72q79_jsyp4scr9h0000gn/T/tmpvj2j9km2.o -fvisibility=hidden
building 'hnswlib' extension
creating build
creating build/temp.macosx-10.9-universal2-cpython-39
creating build/temp.macosx-10.9-universal2-cpython-39/python_bindings
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -I/private/var/folders/cv/dtvck8ws72q79_jsyp4scr9h0000gn/T/pip-build-env-8f2y000v/overlay/lib/python3.9/site-packages/pybind11/include -I/private/var/folders/cv/dtvck8ws72q79_jsyp4scr9h0000gn/T/pip-build-env-8f2y000v/overlay/lib/python3.9/site-packages/numpy/core/include -I./hnswlib/ -I/Users/lifengdi/WorkSpaces/PycharmProjects/langflow/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/include/python3.9 -c ./python_bindings/bindings.cpp -o build/temp.macosx-10.9-universal2-cpython-39/./python_bindings/bindings.o -O3 -march=native -stdlib=libc++ -mmacosx-version-min=10.7 -DVERSION_INFO=\"0.7.0\" -std=c++14 -fvisibility=hidden
clang: error: the clang compiler does not support '-march=native'
error: command '/usr/bin/clang' failed 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 hnswlib
Failed to build hnswlib
ERROR: Could not build wheels for hnswlib, which is required to install pyproject.toml-based projects
解决办法:
export HNSWLIB_NO_NATIVE=1
除非注明,否则均为李锋镝的博客原创文章,转载必须以链接形式标明本文链接
排错也是个耐心的工作啊,ChatGPT有时候也能解决简单的问题,复杂了又要烧脑
@王光卫博客 确实很烧脑,头发头快秃了