python module_error ai_generated true

ModuleNotFoundError: No module named 'setuptools' during pip install -e . (pyproject.toml build backend)

ID: python/pip-build-isolation-missing-setuptools

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-08-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

A pyproject.toml declares setuptools.build_meta as the backend, but the build isolation environment or the project's build-system.requires does not include setuptools.

generic

中文

pyproject.toml 声明 setuptools.build_meta 作为后端,但构建隔离环境或项目的 build-system.requires 未包含 setuptools。

Workarounds

  1. 95% success
    Declare the build requirement in pyproject.toml:
    [build-system]
    requires = ["setuptools>=61", "wheel"]
    build-backend = "setuptools.build_meta"
  2. 90% success
    Install build deps explicitly then build:
    pip install setuptools wheel build
    python -m build

Dead Ends

Common approaches that don't work:

  1. 65% fail

    Uses the current env, which may also lack setuptools or have an incompatible version; masks the real config bug.

  2. 75% fail

    Installs in the outer env but build isolation still creates a fresh env without it.