python install_error ai_generated true

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

ID: python/setuptools-missing-build-system-requires

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

The project's pyproject.toml declares a [build-system] table whose 'requires' omits setuptools (or declares an empty list), so the isolated build env lacks the backend.

generic

中文

项目的 pyproject.toml 声明了 [build-system] 表,但其 'requires' 中缺少 setuptools(或声明为空列表),因此隔离的构建环境缺少该后端。

Workarounds

  1. 97% success
    [build-system]
    requires = ["setuptools>=68", "wheel"]
    build-backend = "setuptools.build_meta"
  2. 90% success
    python -m pip install 'setuptools>=68' wheel
    python -m pip install --no-build-isolation mypkg

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Build isolation creates a fresh env; the current venv's setuptools is not visible.

  2. 75% fail

    Then the build uses the current Python's setuptools, which may be absent or too old.