python install_error ai_generated true

错误:无法为 somepkg 构建 wheel,这是安装基于 pyproject.toml 的项目所必需的 × 获取构建 wheel 的要求未能成功运行。 │ 退出码:1 ╰─> ModuleNotFoundError:没有名为 'flit_core' 的模块

ERROR: Could not build wheels for somepkg, which is required to install pyproject.toml-based projects × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> ModuleNotFoundError: No module named 'flit_core'

ID: python/pip-build-backend-missing

其他格式: JSON · Markdown 中文 · English
80%修复率
88%置信度
0证据数
2025-02-17首次发现

版本兼容性

版本状态引入弃用备注
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

根因分析

项目的 pyproject.toml 声明了一个 PEP 517 构建后端(flit_core、hatchling、poetry-core),但该后端未安装,且由于离线模式或缺少索引而无法获取。

English

The project's pyproject.toml declares a PEP 517 build backend (flit_core, hatchling, poetry-core) that is not installed and cannot be fetched due to offline mode or a missing index.

generic

解决方案

  1. 95% 成功率
    # Inspect the backend
    python - <<'PY'
    import tomllib, pathlib
    print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['build-system'])
    PY
    # Then install it
    pip install flit_core
    pip install .
  2. 90% 成功率
    unset PIP_NO_BUILD_ISOLATION
    unset PIP_NO_INDEX
    pip install --index-url https://pypi.org/simple .

无效尝试

常见但无效的做法:

  1. 85% 失败

    Disables isolation but flit_core still isn't in the current environment, so the same ModuleNotFoundError occurs.

  2. 90% 失败

    The missing module is the declared backend (flit_core), not setuptools/wheel.