python
data_error
ai_generated
true
packaging.markers.UndefinedEnvironmentName:环境标记中未定义 'extra'
packaging.markers.UndefinedEnvironmentName: 'extra' is not defined in environment markers
ID: python/packaging-marker-evaluation-error
80%修复率
82%置信度
0证据数
2025-04-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
标记使用了 'extra',该标记仅在需求文件等特定上下文中有效,并非在所有标记评估中都有效。
English
The marker uses 'extra' which is only valid in certain contexts like requirements files, not in all marker evaluations.
解决方案
-
90% 成功率
Requirement('package; sys_platform == "linux"') -
85% 成功率
from packaging.markers import Marker; m = Marker('extra == "test"'); m.evaluate({'extra': 'test'})
无效尝试
常见但无效的做法:
-
80% 失败
The marker evaluation does not read arbitrary environment variables; 'extra' is a special key.
-
50% 失败
Ignoring may lead to incorrect dependency resolution.