当前位置:   article > 正文

Ubuntu 安装transformers 报错error can‘t find rust compiler_pip install transformers error: can't find rust co

pip install transformers error: can't find rust compiler

问题描述

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

  1. running build_ext
  2. running build_rust
  3. error: can't find Rust compiler
  4. 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.
  5. To update pip, run:
  6. pip install --upgrade pip
  7. and then retry package installation.
  8. 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.
  9. [end of output]
  10. note: This error originates from a subprocess, and is likely not a problem with pip.
  11. ERROR: Failed building wheel for tokenizers
  12. Failed to build tokenizers
  13. ERROR: Could not build wheels for tokenizers, which is required to install pyproject.toml-based projects

解决方案

  1. sudo apt install rustc
  2. 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

安装完毕后依旧报错:

  1. error: [Errno 2] No such file or directory: 'cargo'
  2. [end of output]
  3. note: This error originates from a subprocess, and is likely not a problem with pip.
  4. ERROR: Failed building wheel for tokenizers
  5. Failed to build tokenizers
  6. 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博客

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/946905
推荐阅读
相关标签
  

闽ICP备14008679号