python data_error ai_generated true

packaging.markers.UndefinedEnvironmentName: 'extra' is not defined in environment markers

ID: python/packaging-marker-evaluation-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
82%Confidence
0Evidence
2025-04-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active
3.9 active
3.10 active
3.11 active
3.12 active

Root Cause

The marker uses 'extra' which is only valid in certain contexts like requirements files, not in all marker evaluations.

generic

中文

标记使用了 'extra',该标记仅在需求文件等特定上下文中有效,并非在所有标记评估中都有效。

Workarounds

  1. 90% success
    Requirement('package; sys_platform == "linux"')
  2. 85% success
    from packaging.markers import Marker; m = Marker('extra == "test"'); m.evaluate({'extra': 'test'})

Dead Ends

Common approaches that don't work:

  1. 80% fail

    The marker evaluation does not read arbitrary environment variables; 'extra' is a special key.

  2. 50% fail

    Ignoring may lead to incorrect dependency resolution.