ERROR pip config_error ai_generated true

ERROR: Invalid requirement: 'package[extra1,extra2]' (line 1 of requirements.txt). Hint: = is not a valid operator. Did you mean == ?

ID: pip/conflict-with-requirements-txt-extra

Also available as: JSON · Markdown · 中文
95%Fix Rate
88%Confidence
1Evidence
2023-06-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
pip 22.0 active
pip 23.1 active
pip 24.0 active

Root Cause

A requirements.txt line uses a single equals sign (=) for version pinning after an extras specification, but pip requires double equals (==) for exact version constraints.

generic

中文

requirements.txt 中的一行在 extras 规范后使用了单等号 (=) 进行版本固定,但 pip 要求使用双等号 (==) 表示精确版本约束。

Official Documentation

https://pip.pypa.io/en/stable/reference/requirements-file-format/

Workarounds

  1. 95% success Edit requirements.txt to use double equals: `package[extra1,extra2]==1.0`
    Edit requirements.txt to use double equals: `package[extra1,extra2]==1.0`
  2. 85% success If no version pin is needed, remove the version specifier: `package[extra1,extra2]`
    If no version pin is needed, remove the version specifier: `package[extra1,extra2]`
  3. 70% success Use `pip install -r requirements.txt --no-deps` to bypass the invalid line temporarily, then fix the file.
    Use `pip install -r requirements.txt --no-deps` to bypass the invalid line temporarily, then fix the file.

中文步骤

  1. 编辑 requirements.txt 使用双等号:`package[extra1,extra2]==1.0`
  2. 如果不需要固定版本,移除版本说明符:`package[extra1,extra2]`
  3. 使用 `pip install -r requirements.txt --no-deps` 临时绕过无效行,然后修复文件。

Dead Ends

Common approaches that don't work:

  1. Remove the extras brackets entirely and reinstall without extras. 60% fail

    The user may need the extras for functionality; removing them is a workaround but not a fix.

  2. Change the operator to >= instead of ==. 90% fail

    The error is about the single equals sign, not the operator type; >= also requires double equals.

  3. Ignore the error and use `pip install package[extra1,extra2]==1.0` directly on CLI. 70% fail

    The CLI command works, but the requirements.txt remains broken for future installs or CI.