You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

安装ChromaDB时chroma-hnswlib编译失败,已安装VC++构建工具仍报错,求解决方案或是否需更换向量数据库

安装ChromaDB时chroma-hnswlib编译失败,已安装VC++构建工具仍报错,求解决方案或是否需更换向量数据库
Building wheels for collected packages: chroma-hnswlib
  Building wheel for chroma-hnswlib (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for chroma-hnswlib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [5 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'hnswlib' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for chroma-hnswlib
Failed to build chroma-hnswlib

我已经安装了微软VC++编译器和构建工具以及所有必要依赖,但仍然遇到这个问题,我应该直接换用其他向量数据库吗?

先别急着换数据库,这种情况大概率是VC++构建工具的环境没正确配置到当前终端会话里,或者组件没装全。给你几个排查和解决的方向:

  • 检查VC++构建工具的组件完整性:打开Visual Studio Installer,确认你安装了「C构建工具」下的所有核心组件,尤其是「MSVC v143 - VS 2022 C x64/x86生成工具」(要匹配你Python的架构,32位或64位)、「Windows SDK」(对应你的系统版本),还有「C++ CMake工具 for Windows」这些——有时候默认安装会漏掉部分关键组件。

  • 确保终端加载了VC++环境:如果你用的是普通CMD或PowerShell,得先运行VC++的环境配置脚本。找到Visual Studio安装目录下的vcvarsall.bat(通常路径是C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build),然后根据你的Python架构执行对应命令:比如64位Python就运行vcvarsall.bat x64,运行完成后再重新执行pip安装命令。

  • 尝试预编译的wheel包:可以手动下载适配你Python版本和系统架构的chroma-hnswlib预编译wheel文件,然后用pip install [wheel文件名]来安装,跳过本地编译的步骤。

  • 临时降级chroma-hnswlib版本:新版本的编译要求可能更高,你可以试试安装兼容性更好的旧版本,比如执行pip install chroma-hnswlib==0.7.3,这个版本对VC++环境的适配性相对稳定。

如果以上方法都试过还是无法解决,再考虑更换向量数据库也不迟。比如Pinecone(托管式,无需本地编译)、FAISS(有预编译的Windows版本)、Milvus(提供Windows安装包)这些都是不错的替代选项,开箱即用的场景更多,不需要复杂的编译操作。

备注:内容来源于stack exchange,提问作者Tharunika L

火山引擎 最新活动