# pkg_resources.ContextualVersionConflict：(urllib3 2.0.0 (/usr/lib/python3/dist-packages)，Requirement.parse('urllib3<1.27,>=1.21.1')，{'botocore'})

- **ID:** `python/setuptools-pkg-resources-contextual-version`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pkg_resources 检测到已安装的某个包版本违反了另一个已安装包声明的依赖要求。

## 版本兼容性

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

## 解决方案

1. **** (85% 成功率)
   ```
   pip install 'urllib3>=1.21.1,<1.27'
   ```
2. **** (70% 成功率)
   ```
   pip install --upgrade botocore boto3
   ```
3. **** (90% 成功率)
   ```
   python -m venv .venv && . .venv/bin/activate && pip install -r requirements.txt
   ```

## 无效尝试

- **** — Hides the conflict but the underlying API incompatibility remains and breaks at runtime. (85% 失败率)
- **** — Newer botocore may still pin urllib3<2, and other packages may also require the old version. (60% 失败率)
- **** — pkg_resources ships with setuptools and is required by many packages; removal breaks the environment. (95% 失败率)
