# 错误：无效的依赖项：'requests>=2..0'（来自 requirements.txt 第 1 行）

- **ID:** `python/pip-invalid-requirement-version-specifier`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

requirements.txt 中的版本说明符包含格式错误的版本号（例如双点、尾部操作符或说明符内部有空格），因此 pip 的 packaging 解析器在解析之前就拒绝了整行。

## 版本兼容性

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

## 解决方案

1. **** (98% 成功率)
   ```
   Edit requirements.txt:
  requests>=2.0
Then re-run:
  pip install -r requirements.txt
   ```
2. **** (95% 成功率)
   ```
   python - <<'PY'
from packaging.requirements import Requirement
for i, line in enumerate(open('requirements.txt'), 1):
    line = line.strip()
    if not line or line.startswith('#'):
        continue
    try:
        Requirement(line)
    except Exception as e:
        print(f'line {i}: {line!r} -> {e}')
PY
   ```

## 无效尝试

- **** — pip delegates version parsing to packaging.version; the grammar is strict and unchanged across pip versions, so upgrading does nothing. (90% 失败率)
- **** — Quotes become part of the requirement string and are still parsed as an invalid version, producing the same error. (85% 失败率)
