# packaging.markers.UndefinedEnvironmentName：环境标记中未定义 'extra'

- **ID:** `python/packaging-marker-evaluation-error`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

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

## 无效尝试

- **** — The marker evaluation does not read arbitrary environment variables; 'extra' is a special key. (80% 失败率)
- **** — Ignoring may lead to incorrect dependency resolution. (50% 失败率)
