python config_error ai_generated true

error: In setup.cfg: 'extras_require' must be a dictionary, not a string

ID: python/setuptools-extras-require-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2026-02-28First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

Root Cause

The extras_require configuration is incorrectly set as a plain string instead of a dictionary mapping.

generic

中文

extras_require 配置错误地设置为纯字符串,而不是字典映射。

Workarounds

  1. 95% success Format extras_require as a dictionary in setup.cfg
    [options.extras_require]
    test =
        pytest
        pytest-cov
  2. 90% success Define extras_require in setup.py as a dict
    extras_require={'test': ['pytest', 'pytest-cov']}

Dead Ends

Common approaches that don't work:

  1. Setting extras_require as a list 90% fail

    setuptools expects a dict with extra names as keys.

  2. Omitting extras_require 70% fail

    This removes optional dependencies but may be acceptable.