python config_error ai_generated true

错误:'egg_info' 命令出错:'NoneType' 对象没有属性 'get'

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

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

其他格式: JSON · Markdown 中文 · English
80%修复率
82%置信度
0证据数
2024-07-22首次发现

版本兼容性

版本状态引入弃用备注
3.x active — — —

根因分析

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

English

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

解决方案

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

无效尝试

常见但无效的做法:

  1. 85% 失败

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

  2. 80% 失败

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

  3. 70% 失败

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