重装系统后安装transformers遇到bug,记录一下,方面以后查看。

Windows下使用pip install transformers命令重新安装时,却报错:

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

根据错误提示,首先运行pip install --upgrade pip无效,然后便根据错误的提示需要安装Rust Compiler,首先去其官网下载相应的安装包,根据本人的实际情况选择64位的安装文件,然后点击下载的exe文件进行安装,安装过程中选择默认(default)配置即可。

根据官网的说明Rust所有的工具都在~/.cargo/bin目录,包括rustccargorustup命令,因此需要将其配置到环境变量中,但Windows会进行自动配置,但是配置的环境变量在Windows下需要重启电脑才会生效。在重启后,再次运行安装命令:

pip install transformers

结果是安装成功,截图如下:

outcome

GitHub 加速计划 / tra / transformers
91
5
下载
huggingface/transformers: 是一个基于 Python 的自然语言处理库,它使用了 PostgreSQL 数据库存储数据。适合用于自然语言处理任务的开发和实现,特别是对于需要使用 Python 和 PostgreSQL 数据库的场景。特点是自然语言处理库、Python、PostgreSQL 数据库。
最近提交(Master分支:1 天前 )
66ad8b2d * docs: Details for ambigious channel dimension inference * Update src/transformers/image_utils.py Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> --------- Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> 8 小时前
096f25ae add tokenizer 10 小时前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐