pip install stanza报错Failed to build tokenizers

1.在安装text_mining_tools时候需要安装stanza模块时出现的问题

1.开始使用了python3.5,发现无法调用stanza,查阅得知,stanza不支持3.6以下版本(stanza无download模块)

2.使用python3.6进行安装

pip install stanza -i https://pypi.tuna.tsinghua.edu.cn/simple/

使用报错信息为:

  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.
  ----------------------------------------
  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

通过上面报错信息:给出了两条解决方案,
1.为安装rust
2.为更新pip
通过

easy_install pip

更新,发现pip版本已经最新,无法更新
则去重新安装rust,后发现cmd无法调用rust,不知道是配置原因还是啥

最后是更新了python版本更新为3.7解决了这个问题。

import stanza
stanza.download('en')

2.期间出现过的问题

Script file 'G:\Anaconda\envs\py36\Scripts\pip-script.py' is not present.

报错,我是用过curl

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

再更新pip解决的,其中-o xxx.py,为保存源文件

2.当python文件版本不对,可以直接使用anaconda构建虚拟环境

conda create -n xxx python=3.7
conda info --envs
activate xxx
##如果想升级anaconda原环境版本
conda install python=3.8

3.当安装pip时,出现多个版本pip
报错:

WARNING: Ignoring invalid distribution -ip(地址)

解决方案:删除地址中~开头的文件

https://blog.youkuaiyun.com/weixin_43848614/article/details/118426100

国内源:

清华:https://pypi.tuna.tsinghua.edu.cn/simple/
豆瓣:https://pypi.douban.com/simple
阿里:https://mirrors.aliyun.com/pypi/simple

### 解决方案 当遇到 `Failed to build tokenizers` 的错误时,通常意味着构建过程中遇到了依赖项或环境配置方面的问题。以下是几种常见的解决方法: #### 方法一:指定特定版本的库 有时默认安装最新版的包可能导致兼容性问题。对于 Python 3.6 版本,建议尝试安装特定版本的 `transformers` 和其依赖项来解决问题。 ```bash pip install transformers==3.4.0 ``` 此命令会强制安装与当前环境更兼容的版本[^3]。 #### 方法二:调整Python版本 如果上述操作仍无法解决问题,则考虑降级至 Python 3.8 或升级到更高版本。某些情况下,较新的 Python 版本能更好地支持最新的软件包及其编译需求[^4]。 #### 方法三:使用 Conda 安装 Hugging Face 库 为了避免破坏现有环境中其他工具链(如 NumPy),推荐通过 Anaconda 来管理虚拟环境并安装来自 Hugging Face 社区维护的稳定版本: ```bash conda create -n hf_env python=3.8 conda activate hf_env conda install -c huggingface transformers ``` 这种方法不仅能够有效隔离不同项目的依赖关系,还能减少因直接修改全局解释器而引发的风险。 #### 方法四:手动下载预编译轮子文件(wheel) 若以上措施均告失败,还可以尝试从 PyPI 上获取预先编译好的 `.whl` 文件,并利用 pip 进行离线安装。具体步骤如下: 1. 访问 [https://pypi.org/project/tokenizers/#files](https://pypi.org/project/tokenizers/#files),找到适用于目标平台架构的 wheel; 2. 下载对应的 .whl 文件; 3. 执行以下指令完成安装过程: ```bash pip install path_to_downloaded_wheel_file.whl ``` 这种方式绕过了源码编译环节,从而规避了潜在的操作系统层面差异所带来的障碍[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值