pip install tokenizers==0.12.1 安装错误 – Python 3.6.15 和 Rust 1.72.0 的兼容性问题

问题描述 投票:0回答:1

enter image description here

我在尝试使用命令 pip install tokenizers==0.12.1 安装版本 0.12.1 的 tokenizers 包时遇到问题。我的Python版本是3.6.15,Rust编译器版本是1.72.0。

我尝试通过尝试不同版本的Python和Rust来解决这个问题,但不幸的是,我没有成功。我收到的错误消息是[在此处插入错误消息]。

如果您能提供有关如何解决此兼容性问题并成功安装所需版本的 tokenizers 包的见解或指导,我将不胜感激。

提前感谢您的帮助!

我在尝试使用命令 pip install tokenizers==0.12.1 安装 0.12.1 版本的 tokenizers 包时面临挑战。我的Python版本是3.6.15,我使用的Rust编译器版本是1.72.0。

遇到的错误包括可变警告和转换问题。具体来说:

warning: variable does not need to be mutable
     --> tokenizers-lib\src\models\unigram\model.rs:265:21
      |
  265 |                 let mut target_node = &mut best_path_ends_at[key_pos];
      |                     ----^^^^^^^^^^^
      |                     |
      |                     help: remove this `mut`
  ...
  error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
     --> tokenizers-lib\src\models\bpe\trainer.rs:526:47
      |
  522 |                     let w = &words[*i] as *const _ as *mut _;
      |                             -------------------------------- casting happened here
  ...
  526 |                         let word: &mut Word = &mut (*w);
      |                                               ^^^^^^^^^
      |
      = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
      = note: `#[deny(invalid_reference_casting)]` on by default

warning: `tokenizers` (lib) generated 3 warnings
error: could not compile `tokenizers` (lib) due to the previous error; 3 warnings emitted

我尝试通过删除不必要的 mut 关键字来解决可变警告,但我不确定如何解决转换问题,并且希望获得有关成功安装 tokenizers 包的指导。

感谢您提供的任何帮助!

python compiler-errors rust-cargo huggingface-tokenizers
1个回答
0
投票

你没有说为什么你想具体安装

tokenizers==0.12.1
,但我找到了一个项目,它的要求中包含了:
Stability-AI/generative-models
。我尝试按照他们的说明在 Python 3.11.6 和 Rust 1.74.0 上自行安装,并且能够重现您的错误。

问题似乎是 Rust 编译器 (

rustc
) 在某些时候变得更加严格。从版本 0.14.1 开始,
tokenizers
已修复以适应这种严格性。 (Github 问题表明该问题出现在 Rust 1.73.0 中,并且 1.72.1 有效,但这与您列出的 1.72.0 版本不一致。) 我通过将需求文件(

requirements/pt2.txt

)更改为需要

tokenizers>=0.14.1
transformers>=4.36来使安装成功。 (以前需要
transformers==4.19.1
,但该版本需要
tokenizers<0.13
,从而产生依赖冲突。)
⚠️我不能说该项目是否真的

有效

,只能说它通过此更改编译并安装了。 ⚠️ 这个问题报告了同样的问题:

cargo rustc failed with code 101 - Could not buildwheels for tokenizers,这是安装基于 pyproject.toml 的项目所必需的

。根据那里投票最高的答案,可以通过 rustc 环境变量强制使用较旧(更宽松)版本的

RUSTUP_TOOLCHAIN
    

© www.soinside.com 2019 - 2024. All rights reserved.