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

相关推荐
circuitsosk6 天前
Python 模块与包管理:import 机制、虚拟环境与 pip 完全指南
开发语言·python·pip·依赖管理·模块与包
skywalk816313 天前
pypi 的yank 是什么意思?
pip
Albart57520 天前
【已解决】ModuleNotFoundError_ No module named ‘xxx’ 模块导入失败终极解决
python·pip·环境配置·后端开发·bug解决·模块报错·python导包失败
10mAh20 天前
Python 环境彻底不乱:uv、pip、venv、Conda 怎么选?Windows 项目迁移与锁版本实战
python·pip·uv
doubt。21 天前
RAG与Agent智能体项目实战教程跟练与解析(前置准备与OpenAI库基础使用)
python·ai·pip
二进制杯莫停22 天前
A和B环境的python版本相同,B环境无法安装pip依赖,离线安装
开发语言·python·pip
DFT计算杂谈24 天前
服务器通过pip安装Kimi Code CLI 和使用
运维·服务器·pip
Patrick在香港25 天前
Python依赖管理从踩坑到选型:pip/poetry/uv四种方案全面实测
开发语言·python·数据分析·scikit-learn·ai编程·pip·uv
denggun123451 个月前
大大模型 如何通过 本地排雷 远端GPU
python·embedding·pip
软糖姐姐1 个月前
Python开篇——简介、pip和conda
python·conda·pip·数据科学·