Ubuntu 安装transformers 报错error can‘t find rust compiler

问题描述

Ubuntu 20.04 使用 pip 安装 transformers 库遇到报错:error: can't find Rust compiler. 下面是报错信息的后半部分。 

running build_ext
      running build_rust
      error: can't find Rust compiler

      If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

      To update pip, run:

          pip install --upgrade pip

      and then retry package installation.

      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for tokenizers
Failed to build tokenizers
ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects

解决方案

sudo apt install rustc
sudo apt install cargo

完成上面两个库的安装重新执行 transformers 的安装即可,库较大可能需要 build 一段时间。(我这边用时2分钟左右)

pip install transformers

详细流程

按照提示更新了 pip:

pip install --upgrade pip

但是没有任何作用。报错信息不变。那只能考虑安装 Rust。

参考资料:How to Install Rust on Ubuntu {apt and rustup}

这个用 apt 安装的看上去是最简单的:

sudo apt install rustc

安装完毕后依旧报错:

      error: [Errno 2] No such file or directory: 'cargo'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for tokenizers
Failed to build tokenizers
ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects

然后测试 apt 安装。

sudo apt install cargo

然后重新 pip 安装,问题解决。

相关工作

Windows 下同样问题的解决可参考:安装transformers报错error can‘t find rust compiler_can't find rust compiler-CSDN博客

相关推荐

  1. Ubuntu 安装transformers error can‘t find rust compiler

    2023-12-28 13:50:05       55 阅读
  2. ubuntu22.04 安装软件

    2023-12-28 13:50:05       25 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-28 13:50:05       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-28 13:50:05       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-28 13:50:05       87 阅读
  4. Python语言-面向对象

    2023-12-28 13:50:05       96 阅读

热门阅读

  1. 基于OpenCV的图像颜色与形状识别的原理

    2023-12-28 13:50:05       58 阅读
  2. vue的props

    2023-12-28 13:50:05       56 阅读
  3. DRF之序列化组件

    2023-12-28 13:50:05       40 阅读
  4. Vue 模板编译原理

    2023-12-28 13:50:05       54 阅读
  5. 学习笔记:机器学习

    2023-12-28 13:50:05       79 阅读
  6. 微信小程序电子菜单点菜系统模块代码分析

    2023-12-28 13:50:05       49 阅读