You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Poetry项目无法安装tokenizers(0.13.3)等依赖的问题求助

解决Poetry安装transformers==0.13.3时的PEP517构建错误

问题描述

使用Poetry执行poetry install transformers==0.13.3安装依赖失败,报错:

This error originates from the build backend, and is likely not a problem with poetry but with tokenizers (0.13.3) not supporting PEP 517 builds.

已尝试以下方法但未解决:

  • 执行pip install "transformers==0.13.3" --no-cache-dir直接在虚拟环境安装,但代码无法找到该依赖
  • 尝试通过curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh安装Rust,因sh未识别失败
  • 执行pip wheel --no-cache-dir --use-pep517 "tokenizers (==0.13.3)"仍报相同错误

解决方案

1. 正确安装Rust编译环境

tokenizers 0.13.3依赖Rust环境才能完成编译,不同系统对应安装方式:

  • Windows:直接从Rust官方渠道下载安装包运行,无需使用终端命令
  • macOS/Linux:在终端执行curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash(替换sh为bash,适配多数系统默认shell)
    安装完成后重启终端,执行rustc --version确认环境生效

2. 修改Poetry配置跳过PEP517构建

编辑项目根目录的pyproject.toml,添加tokenizers的构建参数配置:

[tool.poetry.dependencies]
transformers = "0.13.3"
tokenizers = { version = "0.13.3", build = ["--no-use-pep517"] }

保存后执行poetry install重新安装依赖

3. 确保虚拟环境正确激活

pip安装后代码找不到依赖,多是虚拟环境未激活导致:

  • 执行poetry shell激活Poetry创建的虚拟环境
  • 激活后运行代码,或使用poetry run python your_script.py直接执行脚本

4. 降级Poetry版本(可选)

部分新版本Poetry对旧依赖的PEP517兼容性存在问题,可尝试降级到1.2.x版本:

pip install poetry==1.2.2

之后重新执行poetry install transformers==0.13.3

内容的提问来源于stack exchange,提问作者Max Mougg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 22:48:10