python install_error ai_generated true

错误:无法为 foo 构建 wheel,这是安装基于 pyproject.toml 的项目所必需的 ModuleNotFoundError:没有名为 'setuptools' 的模块

ERROR: Could not build wheels for foo, which is required to install pyproject.toml-based projects ModuleNotFoundError: No module named 'setuptools'

ID: python/pip-build-backend-missing-setuptools-legacy

其他格式: JSON · Markdown 中文 · English
80%修复率
84%置信度
0证据数
2024-09-18首次发现

版本兼容性

版本状态引入弃用备注
3.8+ active — — —

根因分析

包的隔离构建环境缺少 setuptools。当构建后端为 setuptools 但构建隔离无法获取它,或在 setuptools 被卸载的环境中运行时发生。

English

The isolated build environment for the package lacks setuptools. This happens when the build backend is setuptools but build isolation cannot fetch it, or when running in an environment where setuptools was uninstalled.

generic

解决方案

  1. 90% 成功率
    python -m pip install --upgrade setuptools wheel
    python -m pip install foo
  2. 85% 成功率
    python -m pip install --upgrade setuptools wheel
    python -m pip install --no-build-isolation foo

无效尝试

常见但无效的做法:

  1. 70% 失败

    Runs the build in the current env; if setuptools isn't installed there either, same error. Also risks version skew.

  2. 90% 失败

    You cannot interact with pip's ephemeral isolated build env; it is torn down automatically.