python config_error ai_generated true

error: error in 'egg_info' command: 'NoneType' object has no attribute 'get'

ID: python/pip-egg-info-metadata-generation-failed

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

A malformed or partially missing setup.cfg/pyproject.toml section causes setuptools' metadata reader to receive None where a dict is expected during egg_info generation.

generic

中文

setup.cfg/pyproject.toml 段落格式错误或缺失,导致 setuptools 的元数据读取器在 egg_info 生成过程中收到 None 而非 dict。

Workarounds

  1. 85% success
    Validate config: python -c "import configparser,sys; c=configparser.ConfigParser(); c.read('setup.cfg'); print(dict(c['metadata']))"
  2. 90% success
    Move metadata into pyproject.toml's [project] table and remove the conflicting setup.cfg section
  3. 80% success
    Run python setup.py egg_info -v to see the full traceback and locate the offending key

Dead Ends

Common approaches that don't work:

  1. 85% fail

    Isolation is not the cause; the malformed metadata file still breaks egg_info.

  2. 80% fail

    The stale directory is regenerated from the same malformed config, reproducing the error.

  3. 70% fail

    A newer setuptools may produce a clearer error but still cannot parse an invalid config.