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

相关推荐
tyn18818 小时前
记录一次conda虚拟环境pip安装报错[WinError 32] 另一个程序正在使用此文件,进程无法访问
windows·conda·pip·虚拟环境·虚环境
量化金策1 天前
枢轴支压点策略
pip·ipython
Levin__NLP_CV_AIGC3 天前
解决pip安装PyPI默认源速度慢
算法·pip
Penguido3 天前
基于 Nexus 在 Dockerfile 配置 yum, conda, pip 仓库的方法和参考
linux·docker·centos·conda·pip
d0ublεU0x004 天前
【生存技能】ubuntu 24.04 如何pip install
linux·ubuntu·pip
未名编程5 天前
【Flask开发踩坑实录】pip 安装报错:“No matching distribution found” 的根本原因及解决方案!
python·flask·pip
Xudde.5 天前
加速pip下载:永久解决网络慢问题
网络·python·学习·pip
ssslar5 天前
Flutter PIP 插件 ---- 为iOS 重构PipController, Demo界面,更好的体验
flutter·pip
草巾冒小子8 天前
python3使用:macOS上通过Homebrew安装pip库
macos·pip
ssslar11 天前
Flutter PIP 插件 ---- 新增PipActivity,Android 11以下支持自动进入PIP Mode
android·flutter·pip