python install_error ai_generated true

FileNotFoundError: [Errno 2] No such file or directory: 'setup.py' ERROR: Failed to build 'foo' when getting requirements to build wheel

ID: python/setuptools-no-setup-py

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2025-03-19First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

The project has no setup.py (pyproject.toml-only) but a tool or pip invocation assumes the legacy setup.py entry point, or the working directory is wrong.

generic

中文

项目没有 setup.py(仅 pyproject.toml),但某个工具或 pip 调用假定使用旧的 setup.py 入口,或工作目录错误。

Workarounds

  1. 92% success
    Add a minimal pyproject.toml with a build backend:
    [build-system]
    requires = ["setuptools>=61"]
    build-backend = "setuptools.build_meta"
    
    [project]
    name = "foo"
    version = "1.0.0"
  2. 85% success
    Confirm you are in the project root:
    ls pyproject.toml setup.py setup.cfg
    pip install .

Dead Ends

Common approaches that don't work:

  1. 85% fail

    An empty setup.py makes the build fail later with 'no commands supplied' or metadata errors.

  2. 70% fail

    Still expects a build backend; if pyproject.toml is missing, there is nothing to build.