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即可

相关推荐
tryCbest13 天前
Windows环境下配置pip镜像源
windows·pip
百锦再13 天前
Django实现接口token检测的实现方案
数据库·python·django·sqlite·flask·fastapi·pip
coding者在努力14 天前
LangChain之解析器核心组件.2026年新版讲解,超详细
windows·python·机器学习·langchain·pip
wumingxiaoyao15 天前
从 requirements.txt 到 uv:多模块 Monorepo 的依赖管理升级指南(用法、特点、区别与最佳实践 + 例子)
pip·uv·pip tool
HrxXBagRHod23 天前
三相三电平维也纳整流器Simulink仿真模型探索
pip
张3蜂23 天前
Python pip 命令完全指南:从入门到精通
人工智能·python·pip
码云数智-大飞25 天前
PyCharm 安装 Python 模块失败?常见 pip 报错原因与解决方案全解析
python·pycharm·pip
skywalk81631 个月前
windows10 pip安装ete4报错
开发语言·python·pip
Albert Edison1 个月前
【Python】列表|元组
开发语言·python·pip
CYpdpjRnUE1 个月前
MPU9250模块SPI驱动程序:原始数据读取与I2C主机模式配置AK8963磁力计教程
pip