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

相关推荐
沧海一笑-dj6 天前
【Python】Python学习笔记-模块与包
python·pip·模块·包·python包·python模块·包与模块
郝学胜-神的一滴7 天前
AI 编程智能体 16:从零基础搭建到精细化优化
人工智能·python·算法·语言模型·langchain·pip
All The Way North-8 天前
Transformers 5.19.0 源码阅读:AutoTokenizer.decode() 原生批处理与 BPE 空格清理陷阱
transformers·tokenizer·版本更新·decode·源码解读·autotokenizer·v 5.19
All The Way North-9 天前
Transformers 5.19.0 首发源码研读:Tokenizer.call() 核心机制与实战验证
huggingface·transformers·qwen·tokenizer·源码解读·autotokenizer·v 5.19
万粉变现经纪人9 天前
如何解决 pip install 安装报错 检测到 yanked 版本需更换可用版本 问题
人工智能·python·scrapy·numpy·pandas·pyqt·pip
jiangliushi611 天前
GPT-6.1 Sol 免费用:pip install 太慢、超时?换清华镜像,再让 Codex 帮你写脚本
gpt·pip
看我debug14 天前
Android 运行时分析工作台 (Demo)。统一管理 Frida 脚本、自动注入(修改运行时代码)、收集结构化结果、生成 JSON 报告。
android·python·pip
余槐i17 天前
transformers 升级后加载旧权重报错:三处不兼容如何逐一验证
python·大模型·transformers·模型量化·模型推理
死磕音视频19 天前
让小模型做选择题:限定候选项并读取 logits 概率的入门实践(附 Python 代码)
开发语言·python·大模型·文本分类·transformers
Escalating_xu1 个月前
【Python】使用库:标准库、第三方库、pip、项目实战与程序打包
java·python·pip