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

相关推荐
资深设备全生命周期管理16 小时前
在线测试来料公差
python·pip
bjxiaxueliang2 天前
一文详解PyTorch环境搭建:M芯Mac通过pip安装PyTorch开发环境
pytorch·macos·pip
ssslar8 天前
Flutter PIP 插件 ---- iOS Video Call 自定义PIP WINDOW渲染内容
flutter·ios·pip
假意诗人11 天前
Python3笔记之号称替代pip的uv包管理器
python·pip·uv
猫头虎11 天前
最新如何在服务器中解决FFmpeg下载、安装和配置问题教程(Linux|Windows|Mac|Ubuntu)
linux·服务器·windows·ffmpeg·音视频·pip·视频编解码
GDAL12 天前
Conda与Pip:Python包管理工具的对比与选型
python·conda·pip
再玩一会儿看代码13 天前
pip 与 conda 的全面比较:Python 包管理的深度解析
经验分享·笔记·python·conda·课程设计·pip
Eiceblue13 天前
使用Python写入JSON、XML和YAML数据到Excel文件
xml·开发语言·vscode·python·json·excel·pip
Jackilina_Stone13 天前
transformers:打造的先进的自然语言处理
人工智能·自然语言处理·transformers
李雨非-19期-河北工职大14 天前
“pip“ is not recognized(pip无法被识别)
pip