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

相关推荐
猫头虎1 天前
零基础安装 Python 教程:从下载到环境配置一步到位(支持 VSCode 和 PyCharm)与常用操作系统操作指南
vscode·python·pycharm·beautifulsoup·numpy·pyqt·pip
代码讲故事6 天前
解决 xmlsec.InternalError: (-1, ‘lxml & xmlsec libxml2 library version mismatch‘)
linux·python·pip·lxml·xmlsec·libxml2
猫头虎10 天前
PyTorch入门教程:下载、安装、配置、参数简介、DataLoader(数据迭代器)参数解析与用法合集
人工智能·pytorch·python·深度学习·机器学习·pandas·pip
于归pro15 天前
Python环境管理工具深度指南:pip、Poetry、uv、Conda
python·pip·uv
水花花花花花17 天前
GloVe 模型讲解与实战
python·深度学习·conda·pip
正在走向自律19 天前
Conda 完全指南:从环境管理到工具集成
开发语言·python·conda·numpy·fastapi·pip·开发工具
小猪写代码19 天前
在 Ubuntu 20.04.6 LTS 中将 SCons 从 3.1.2 升级到 4.9.1
chrome·ubuntu·pip
tyn18822 天前
记录一次conda虚拟环境pip安装报错[WinError 32] 另一个程序正在使用此文件,进程无法访问
windows·conda·pip·虚拟环境·虚环境
量化金策22 天前
枢轴支压点策略
pip·ipython
Levin__NLP_CV_AIGC24 天前
解决pip安装PyPI默认源速度慢
算法·pip