pip install transformers教程

直接pip install transformers会报错,报错内容如下:

shell 复制代码
Collecting safetensors>=0.3.1 (from transformers)
  Using cached safetensors-0.5.2.tar.gz (66 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing 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.

重点是Cargo, the Rust package manager, is not installed or is not on PATH这句话,所以可能Rust没有安装,那我们安装Rust,参考网址,具体步骤:

shell 复制代码
# 确认一下你的curl是不是用snap安装的
sudo snap list | grep curl
# 如果是,卸载
sudo snap remove curl
# 然后用apt重新安装
sudo apt install curl
# 安装Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# 添加环境变量
source $HOME/.cargo/env
# 测试是否安装成功
rustc -V 

Rust安装成功后再pip install transformers即可

相关推荐
二进制杯莫停2 天前
A和B环境的python版本相同,B环境无法安装pip依赖,离线安装
开发语言·python·pip
DFT计算杂谈3 天前
服务器通过pip安装Kimi Code CLI 和使用
运维·服务器·pip
Patrick在香港4 天前
Python依赖管理从踩坑到选型:pip/poetry/uv四种方案全面实测
开发语言·python·数据分析·scikit-learn·ai编程·pip·uv
denggun123455 天前
大大模型 如何通过 本地排雷 远端GPU
python·embedding·pip
软糖姐姐7 天前
Python开篇——简介、pip和conda
python·conda·pip·数据科学·
不明觉厉二十年8 天前
uv Windows配置
conda·pip
IT界的老黄牛12 天前
uv 常用命令速查:一个工具干掉 pip + venv + pyenv + pipx + poetry,Python 工具链从此清爽
python·pip·uv·虚拟环境·包管理·命令速查
Yolanda_202212 天前
在vscode终端中可使用pip,但是cmd终端中找不到命令 pip问题的解决
vscode·python·conda·pip
Yolanda_202212 天前
pip安装jieba报错:由于目标计算器积极拒绝,无法连接
pip
lxw184491251414 天前
Python uv 完整使用教程
python·conda·pip·uv