python config_error ai_generated true

ERROR: Invalid config file: /home/user/.config/pip/pip.conf TOMLDecodeError: Expected '=' after a key in a key/value pair (at line 3, column 4)

ID: python/pip-pip-conf-invalid-toml

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2024-09-27First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

Root Cause

pip.conf (or pip.toml) contains malformed TOML/INI — a missing '=', a stray quote, or mixing INI and TOML syntax. pip refuses to read any config, so every pip command fails.

generic

中文

pip.conf(或 pip.toml)包含格式错误的 TOML/INI——缺少 '='、多余的引号,或混合了 INI 和 TOML 语法。pip 拒绝读取任何配置,所有 pip 命令都失败。

Workarounds

  1. 95% success
    # ~/.config/pip/pip.conf
    [global]
    index-url = https://pypi.org/simple
    timeout = 60
  2. 90% success
    python -c "import tomllib; tomllib.load(open('/home/user/.config/pip/pip.conf','rb'))"
  3. 85% success
    PIP_CONFIG_FILE=/dev/null pip install <pkg>

Dead Ends

Common approaches that don't work:

  1. 95% fail

    pip can't read its config to start.

  2. 90% fail

    Config parsing happens before cache logic.

  3. 85% fail

    The malformed config file is still parsed and errors.