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

相关推荐
诸神缄默不语5 小时前
Re78 读论文:GPT-4 Technical Report
chatgpt·llm·论文·openai·transformers·大规模预训练语言模型·gpt-4
wangjinyu1244199 小时前
Subprocess check_output returned non-zero exit status 1
开发语言·python·pip
三劫散仙1 天前
conda 依赖固定和 pip 依赖使用的区别
python·conda·pip
新手小袁_J4 天前
Python实现简单的缺失值处理(超详细教程)
开发语言·python·信息可视化·numpy·pandas·matplotlib·pip
新手小袁_J9 天前
Python的Matplotlib库应用(超详细教程)
开发语言·python·numpy·matplotlib·pip·基础知识
亦梦亦醒乐逍遥10 天前
conda/pip基本常用命令理解与整理
conda·pip
floenrce15 天前
pip安装paddle失败
python·pip
计算机学姐16 天前
基于Python的社交音乐分享平台
开发语言·vue.js·python·mysql·django·flask·pip
新手小袁_J17 天前
Python的列表基础知识点(超详细流程)
开发语言·python·numpy·pip·基础知识·基础知识点