# 错误：无法安装 package-a[extra1,extra2]==1.0 和 package-b==2.0，因为这些包版本存在依赖冲突。冲突由以下原因引起：package-a 1.0 依赖 package-c>=3.0，而 package-b 2.0 依赖 package-c<3.0。

- **ID:** `pip/dependency-conflict-with-extras`
- **领域:** pip
- **类别:** install_error
- **错误码:** `ERROR`
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

两个请求的包对共享依赖项有互斥的版本约束，pip 的解析器无法找到同时满足两个约束的共享依赖版本。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 23.2 | active | — | — |
| pip 24.1 | active | — | — |
| pip 24.2 | active | — | — |

## 解决方案

1. ```
   安装旧版本的 package-a，该版本依赖于 package-c<3.0：pip install 'package-a[extra1,extra2]<1.0' package-b==2.0
   ```
2. ```
   使用虚拟环境，安装同时满足两个条件的 package-c 版本（例如 package-c==2.99），然后不安装依赖地安装包：pip install package-c==2.99 && pip install --no-deps package-a[extra1,extra2]==1.0 package-b==2.0
   ```
3. ```
   联系包维护者放宽版本约束，或使用解决冲突的分支。
   ```

## 无效尝试

- **Force install both packages with --no-deps to skip dependency resolution** — While this allows installation, the conflicting dependency package-c will be missing or have an incompatible version, causing runtime ImportError or AttributeError. (85% 失败率)
- **Upgrade pip to the latest version hoping the resolver improves** — The conflict is fundamental to the version constraints; no resolver can satisfy mutually exclusive requirements unless constraints are relaxed. (70% 失败率)
