重装系统后安装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
目录,包括rustc
、cargo
和rustup
命令,因此需要将其配置到环境变量中,但Windows会进行自动配置,但是配置的环境变量在Windows下需要重启电脑才会生效。在重启后,再次运行安装命令:
pip install transformers
结果是安装成功,截图如下: