python
runtime_error
ai_generated
true
pkg_resources.VersionConflict: (foo 1.0 (/usr/lib/python3/dist-packages), Requirement.parse('foo>=2.0'))
ID: python/setuptools-could-not-find-version-satisfying
80%Fix Rate
87%Confidence
0Evidence
2024-04-08First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
Root Cause
At import time, pkg_resources checks installed distributions and finds a version that does not satisfy a declared requirement, often because two packages were installed into different site-packages directories.
generic中文
在导入时,pkg_resources 检查已安装的发行版,发现某个版本不满足声明的需求,通常是因为两个包被安装到不同的 site-packages 目录。
Workarounds
-
90% success
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'
-
90% success
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
Dead Ends
Common approaches that don't work:
-
70% fail
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.
-
75% fail
Hides the version mismatch; the package may call APIs that do not exist in the old version and crash later.