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

重装系统后安装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

安装transformer报错可能有几种原因和解决方法。首先,如果安装速度慢且出现TimeoutError,可以尝试使用镜像进行安装。 其次,如果提示安装成功但在import时出现错误提示"None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.",原因可能是tensorflow和transformers使用了不同的安装方法。例如,tensorflow是在anaconda prompt中安装的,但是transformers可能使用了cmd进行安装。解决方法是先卸载已安装transformers(在cmd中使用命令pip uninstall transformers),然后在anaconda prompt中重新安装一遍。 具体的安装方式如下:首先,打开anaconda prompt,在命令行中输入"pip install -i https://pypi.tuna.tsinghua.edu.cn/simple transformers"进行安装安装完成后,可以使用"import transformers"进行检测,如果没有报错,则说明安装成功。 另外,如果出现错误详情为"ERROR: Command errored out with exit status 1: command: '/Users/XXX/...' '/Users/XXX/..._in_process.py' build_wheel '/Users/XXX/...' cwd: /Users/XXX/.../pip-install-sza2_lmj\tokenizers Complete output (10 lines): running bdist_wheel running build running build_py creating build creating build\lib creating build\lib\tokenizers copying tokenizers\__init__.py -> build\lib\tokenizers running build_ext running build_rust error: Can not find Rust compiler ERROR: Failed building wheel for tokenizers Failed to build tokenizers ERROR: Could not build wheels for tokenizers which use PEP 517 and cannot be installed directly",可能是由于缺少Rust编译器导致的。 解决此问题的方法是安装Rust编译器。可以从官方网站(https://www.rust-lang.org/tools/install)下载并按照指示安装安装完成后,再次尝试安装transformers,应该就能成功了。 综上所述,安装transformer报错可能是由于安装速度慢、安装方法不正确或缺少Rust编译器等原因导致的。根据具体的错误提示,可以尝试使用镜像进行安装、重新安装transformers安装Rust编译器来解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

斯曦巍峨

码文不易,有条件的可以支持一下

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值