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

相关推荐
向qian看_-_2 天前
Linux 使用pip报错(error: externally-managed-environment )解决方案
linux·python·pip
酷飞飞3 天前
错误是ModuleNotFoundError: No module named ‘pip‘解决“找不到 pip”
人工智能·python·pip
吐个泡泡v3 天前
Python包管理工具全对比:pip、conda、Poetry、uv、Flit深度解析
conda·pip·uv·python包管理工具·poetry
Yokon_D4 天前
Pycharm终端pip install的包都在C:\Users\\AppData\Roaming\Python\解决办法
python·pycharm·pip
xzl045 天前
pip的缓存
缓存·pip
Dontla5 天前
pip completion工具作用(生成命令行自动补全脚本)(与pip-bash-completion区别)
chrome·bash·pip
万粉变现经纪人12 天前
如何解决pip安装报错ModuleNotFoundError: No module named ‘websockets’问题
ide·pycharm·beautifulsoup·pandas·fastapi·pip·httpx
vortex513 天前
Python包管理与安装机制详解
linux·python·pip
Ciel_752113 天前
AmazeVault 核心功能分析,认证、安全和关键的功能
python·pyqt·pip
躺不平的小刘17 天前
从YOLOv5到RKNN:零冲突转换YOLOv5模型至RK3588 NPU全指南
linux·python·嵌入式硬件·yolo·conda·pyqt·pip