python install_error ai_generated true

error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output.

ID: python/pip-install-metadata-generation-failed

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2024-03-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

Root Cause

pip uses PEP 517 build isolation to build wheel metadata in an isolated environment. If the build backend (setuptools, hatchling, poetry-core) is missing or a build dependency is not declared in pyproject.toml, metadata generation fails before the actual install.

generic

中文

pip 使用 PEP 517 构建隔离在独立环境中构建 wheel 元数据。如果构建后端(setuptools、hatchling、poetry-core)缺失或构建依赖未在 pyproject.toml 中声明,元数据生成会在实际安装前失败。

Workarounds

  1. 85% success
    pip install setuptools wheel
    pip install --no-build-isolation ./mypackage
  2. 90% success
    [build-system]
    requires = ["setuptools>=64", "wheel", "cython"]
    build-backend = "setuptools.build_meta"
  3. 80% success
    pip install -v ./mypackage 2>&1 | grep -A5 'Error'

Dead Ends

Common approaches that don't work:

  1. 55% fail

    Disables isolation but the missing build dependency is still not present in the current environment, so the backend import fails anyway.

  2. 70% fail

    The failure is in the build backend invocation, not a corrupted download; clearing cache does not add missing build deps.

  3. 60% fail

    Newer pip still respects pyproject.toml build-system requirements; the missing dependency is unchanged.