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.
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.
python -m pip install --upgrade pip setuptools wheelStop importing dependencies in setup.py
Read version and metadata without importing the package; declare build deps in [build-system] requires instead.
[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.