python config_error ai_generated true

ERROR: Invalid constraint line in constraints.txt: 'package1' - Expected a version specifier

ID: python/pip-invalid-constraint-file

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2025-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

Root Cause

A constraint file must contain package names with version specifiers (e.g., package1>=1.0), but a bare package name was found.

generic

中文

约束文件必须包含带有版本说明符的包名(例如 package1>=1.0),但发现了一个裸包名。

Workarounds

  1. 95% success
    echo 'package1>=1.0' >> constraints.txt
  2. 90% success
    sed -i '/^package1$/d' constraints.txt

Dead Ends

Common approaches that don't work:

  1. 100% fail

    Comments are ignored; the invalid line still causes error.

  2. 60% fail

    Constraints files have different syntax; using them as requirements may fail.