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

相关推荐
蜗牛去旅行吧3 天前
解决 `pip is configured with locations that require TLS/SSL` 错误
网络协议·ssl·pip
来自于狂人3 天前
解决 `pip install open-webui` 时的编译错误:Microsoft Visual C++ 14.0 或更高版本缺失
c++·microsoft·pip
余将董道而不豫兮5 天前
pip 与 conda 的故事
人工智能·python·深度学习·conda·pip
Yuezero_6 天前
【BUG】conda虚拟环境下,pip install安装直接到全局python目录中
pytorch·python·conda·bug·pip
uncle_ll6 天前
复制conda虚拟环境的几种方法
conda·pip·虚拟环境·pyenv·minconda
ssslar8 天前
Flutter PIP 插件 ---- iOS Video Call
flutter·ios·pip
ssslar9 天前
Flutter PIP 插件 ---- Android
android·flutter·pip
cuber膜拜15 天前
Linux(Centos)安装allnnlp失败,jsonnet报错
linux·centos·pip
纪伊路上盛名在23 天前
生信软件管家——conda vs pip
linux·python·conda·学习方法·pip
Lucky_Turtle24 天前
maven、npm、pip、yum官方镜像修改文档
npm·maven·pip