# 错误：无效的需求：'--extra-index-url https://example.com/simple'（来自 requirements.txt 第 3 行）
提示：需求必须采用 'package[extras]==version' 的形式。

- **ID:** `python/pip-requirements-parse-error-options`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

像 --extra-index-url 这样的全局选项被放在 requirements.txt 中某个包行之后；pip 只接受位于文件顶部的全局选项，在任何需求之前。

## 版本兼容性

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

## 解决方案

1. **** (98% 成功率)
   ```
   Move all global options to the top of requirements.txt:
  --extra-index-url https://example.com/simple
  --trusted-host example.com
  foo==1.2.3
  bar>=2.0
   ```
2. **** (95% 成功率)
   ```
   Alternatively pass options on the CLI:
  pip install -r requirements.txt --extra-index-url https://example.com/simple
   ```

## 无效尝试

- **** — Quoting turns it into an invalid package name; pip still rejects it. (95% 失败率)
- **** — Global options are only valid before the first requirement; moving to the end does not help. (90% 失败率)
