Cargo, the Rust package manager, is not installed or is not on PATH.

发布于:2025-04-04 ⋅ 阅读:(25) ⋅ 点赞:(0)

今天安装tokenizers报错,如下图:

C:\Users\xiongpeng\LLaMA-Factory\tokenizers\bindings\python>pip install -e .\
Obtaining file:///C:/Users/xiongpeng/LLaMA-Factory/tokenizers/bindings/python
  Installing build dependencies ... canceled
ERROR: Operation cancelled by user

C:\Users\xiongpeng\LLaMA-Factory\tokenizers\bindings\python>pip install -e .
Obtaining file:///C:/Users/xiongpeng/LLaMA-Factory/tokenizers/bindings/python
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing editable metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]

      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....
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

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

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

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

下一步选择 , 直接点击回车 , 默认安装即可 ;安装过程中 , 会下载相关依赖 , 等待下载安装完成 ;

安装完成后,执行下列命令:

rustc --version
cargo --version

如下图:

再执行之前的安装命令即可。