一、错误记录



执行 pip install chromadb 命令 , 安装 向量数据库 chromadb , 执行后报错 ;

在这里插入图片描述

核心报错信息 :

    Cargo, the Rust package manager, is not installed or is not on PATH.
    This package requires Rust and Cargo to compile extensions. Install it through
    the system's package manager or via https://rustup.rs/

    Checking for Rust toolchain....

完整报错信息 :

C:\Users\octop>pip install chromadb
Collecting chromadb
  Downloading chromadb-0.4.14-py3-none-any.whl (448 kB)
     |████████████████████████████████| 448 kB 93 kB/s
Collecting pypika>=0.48.9
  Downloading PyPika-0.48.9.tar.gz (67 kB)
     |████████████████████████████████| 67 kB 60 kB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting overrides>=7.3.1
  Downloading overrides-7.7.0-py3-none-any.whl (17 kB)
Requirement already satisfied: grpcio>=1.58.0 in d:\001_develop\022_python\python37_64\lib\site-packages (from chromadb) (1.62.3)
Collecting graphlib-backport>=1.0.3; python_version < "3.9"
  Downloading graphlib_backport-1.1.0-py3-none-any.whl (7.1 kB)
Requirement already satisfied: numpy==1.21.6; python_version < "3.8" in d:\001_develop\022_python\python37_64\lib\site-packages (from chromadb) (1.21.6)
Requirement already satisfied: typer>=0.9.0 in d:\001_develop\022_python\python37_64\lib\site-packages (from chromadb) (0.15.1)
Collecting fastapi>=0.95.2
  Downloading fastapi-0.103.2-py3-none-any.whl (66 kB)
     |████████████████████████████████| 66 kB 138 kB/s
Requirement already satisfied: tqdm>=4.65.0 in d:\001_develop\022_python\python37_64\lib\site-packages (from chromadb) (4.66.4)
Requirement already satisfied: importlib-resources in d:\001_develop\022_python\python37_64\lib\site-packages (from chromadb) (5.12.0)
Requirement already satisfied: typing-extensions>=4.5.0 in d:\001_develop\022_python\python37_64\lib\site-packages (from chromadb) (4.7.1)
Collecting posthog>=2.4.0
  Downloading posthog-3.18.0-py2.py3-none-any.whl (76 kB)
     |████████████████████████████████| 76 kB 217 kB/s
Collecting pulsar-client>=3.1.0
  Downloading pulsar_client-3.3.0-cp37-cp37m-win_amd64.whl (3.4 MB)
     |████████████████████████████████| 3.4 MB 819 kB/s
Collecting uvicorn[standard]>=0.18.3
  Downloading uvicorn-0.22.0-py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 727 kB/s
Collecting bcrypt>=4.0.1
  Downloading bcrypt-4.2.1-cp37-abi3-win_amd64.whl (152 kB)
     |████████████████████████████████| 152 kB 656 kB/s
Collecting chroma-hnswlib==0.7.3
  Downloading chroma_hnswlib-0.7.3-cp37-cp37m-win_amd64.whl (152 kB)
     |████████████████████████████████| 152 kB 726 kB/s
Requirement already satisfied: pydantic>=1.9 in d:\001_develop\022_python\python37_64\lib\site-packages (from chromadb) (2.5.3)
Requirement already satisfied: requests>=2.28 in d:\001_develop\022_python\python37_64\lib\site-packages (from chromadb) (2.31.0)
Collecting tokenizers>=0.13.2
  Downloading tokenizers-0.21.0.tar.gz (343 kB)
     |████████████████████████████████| 343 kB 819 kB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: 'd:\001_develop\022_python\python37_64\python.exe' 'd:\001_develop\022_python\python37_64\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\octop\AppData\Local\Temp\tmpdpqiqp98'
         cwd: C:\Users\octop\AppData\Local\Temp\pip-install-0tgg_fb8\tokenizers
    Complete output (6 lines):

    Cargo, the Rust package manager, is not installed or is not on PATH.
    This package requires Rust and Cargo to compile extensions. Install it through
    the system's package manager or via https://rustup.rs/

    Checking for Rust toolchain....
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'd:\001_develop\022_python\python37_64\python.exe' 'd:\001_develop\022_python\python37_64\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\octop\AppData\Local\Temp\tmpdpqiqp98' Check the logs for full command output.
WARNING: You are using pip version 20.1.1; however, version 24.0 is available.
You should consider upgrading via the 'd:\001_develop\022_python\python37_64\python.exe -m pip install --upgrade pip' command.

C:\Users\octop>

报错截图 :
在这里插入图片描述





二、解决方案



解读报错信息 :

Cargo, the Rust package manager, is not installed or is not on PATH. This package requires Rust and Cargo to compile extensions. Install it through the system’s package manager or via https://rustup.rs/

Rust 包管理器 Cargo 未安装或未添加到 PATH 中。此包需要 Rust 和 Cargo 来编译扩展。请通过系统的包管理器或访问 https://rustup.rs/ 进行安装。


安装 chromadb 向量数据库 时因缺少 Rust 和 Cargo 导致错误 , 需先安装 Rust 工具链(包含 Cargo), 然后重新执行 " pip install chromadb " 安装命令 ;

https://rustup.rs/ 网站 , 下载 rust 安装包 rustup-init.exe ; 点击下图中的链接 , 即可下载 ;

下载地址为 https://win.rustup.rs/x86_64 ;

在这里插入图片描述

运行 上述 rustup-init.exe 程序 , 弹出如下对话框 :

在这里插入图片描述

上述对话框的内容如下 :

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  C:\Users\octop\.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  C:\Users\octop\.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  C:\Users\octop\.cargo\bin

This path will then be added to your PATH environment variable by
modifying the HKEY_CURRENT_USER/Environment/PATH registry key.

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-pc-windows-msvc
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>

在上述命令行中 , 给出了 C:\Users\octop.cargo\bin 的路径 , 这是 Cargo 可执行程序的目录 , 必须将该目录配置到 Path 环境中 , 才能解决 Cargo, the Rust package manager, is not installed or is not on PATH. 报错 ;


下一步选择 , 直接点击回车 , 默认安装即可 ;

安装过程中 , 会下载相关依赖 , 等待下载安装完成 ;

在这里插入图片描述

安装完成后 , 执行如下两个命令 , 查看是否安装完成 ;

rustc --version
cargo --version

之后 , 命令行输入 这两个版本号 ;

C:\Users\octop>rustc --version
rustc 1.85.0 (4d91de4e4 2025-02-17)

C:\Users\octop>cargo --version
cargo 1.85.0 (d73d2caf9 2024-12-31)

C:\Users\octop>

在这里插入图片描述

继续执行

pip install chromadb

命令 , 即可安装 向量数据库 chromadb 成功 ;

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐