Skip to content
Latchkey

Python "setup.py egg_info" failed in CI

pip invoked setup.py egg_info to read project metadata and the script exited non-zero. The real cause - an import in setup.py, a missing build dependency, or an old setuptools - is in the captured output.

What this error means

pip fails with "Command \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-.../" while preparing a package for install.

pip
    ModuleNotFoundError: No module named 'setuptools'
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-abc/legacy-pkg/

Common causes

setup.py imports something at top level

The script imports a package (numpy, the project itself) before dependencies exist, so reading metadata fails.

Missing or outdated setuptools

A build env without setuptools (or with a very old one) cannot run the legacy egg_info command.

How to fix it

Upgrade build tooling

Provide a modern setuptools and wheel so egg_info has what it needs.

Terminal
python -m pip install --upgrade pip setuptools wheel

Stop importing dependencies in setup.py

Read version and metadata without importing the package; declare build deps in [build-system] requires instead.

pyproject.toml
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

How to prevent it

  • Avoid importing runtime dependencies inside setup.py.
  • Declare build deps in [build-system] requires.
  • Upgrade pip/setuptools/wheel as the first CI step.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →