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

相关推荐
coding者在努力12 小时前
LangChain之解析器核心组件.2026年新版讲解,超详细
windows·python·机器学习·langchain·pip
wumingxiaoyao1 天前
从 requirements.txt 到 uv:多模块 Monorepo 的依赖管理升级指南(用法、特点、区别与最佳实践 + 例子)
pip·uv·pip tool
HrxXBagRHod9 天前
三相三电平维也纳整流器Simulink仿真模型探索
pip
张3蜂9 天前
Python pip 命令完全指南:从入门到精通
人工智能·python·pip
码云数智-大飞11 天前
PyCharm 安装 Python 模块失败?常见 pip 报错原因与解决方案全解析
python·pycharm·pip
skywalk816314 天前
windows10 pip安装ete4报错
开发语言·python·pip
Albert Edison15 天前
【Python】列表|元组
开发语言·python·pip
CYpdpjRnUE16 天前
MPU9250模块SPI驱动程序:原始数据读取与I2C主机模式配置AK8963磁力计教程
pip
TTGGGFF17 天前
UV详解:替代pip、conda的下一代Python包与环境管理工具
conda·pip·uv
猫头虎18 天前
如何解决 OpenClaw “Pairing required” 报错:两种官方解决方案详解
网络·windows·网络协议·macos·智能路由器·pip·scipy