# pkg_resources.VersionConflict: (foo 1.0 (/usr/lib/python3/dist-packages), Requirement.parse('foo>=2.0'))

- **ID:** `python/setuptools-could-not-find-version-satisfying`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在导入时，pkg_resources 检查已安装的发行版，发现某个版本不满足声明的需求，通常是因为两个包被安装到不同的 site-packages 目录。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Check which foo is found:
  python -c "import foo; print(foo.__file__)"
  pip show foo
Then uninstall the old one:
  pip uninstall foo
  pip install 'foo>=2.0'
   ```
2. **** (90% 成功率)
   ```
   Use a virtualenv with --system-site-packages disabled so the system dist-packages does not shadow your venv:
  python -m venv .venv  # do NOT pass --system-site-packages
  source .venv/bin/activate
  pip install foo
   ```

## 无效尝试

- **** — If the old foo is in the system dist-packages and pip installs to user site-packages, pkg_resources may still find the old one first. (70% 失败率)
- **** — Hides the version mismatch; the package may call APIs that do not exist in the old version and crash later. (75% 失败率)
