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

相关推荐
deepin_sir1 天前
02 pip 与包管理基础——你的第一个包管理工具
pip
xing-xing1 天前
PIP工具学习总结
python·pip
消失的旧时光-19432 天前
第四篇:Point-In-Polygon 是什么?——机器人电子围栏核心算法
机器人·pip·rtk
开发者联盟league3 天前
pip install出现报错ERROR: Cannot set --home and --prefix together
开发语言·python·pip
开发者联盟league6 天前
linux普通用户使用pip安装模块
linux·python·pip
九成宫7 天前
WSL2 网络优化配置:提升Git克隆与包下载速度
windows·笔记·代理模式·pip·wsl
m0_6174939410 天前
pip安装zxing-cpp报错“returned non-zero exit status 1”的完美解决方案
pip
咕噜咕噜啦啦11 天前
RTX5090配置DGL
pytorch·python·conda·pip
马优晨14 天前
Pip 和 Conda 是什么关系?
conda·pip·pip 和 conda 关系·conda和pip的关系·pip和conda是什么
金玉满堂@bj15 天前
# Groovy Pipeline 详解
pip