python
config_error
ai_generated
true
错误:无法同时安装 Foo-Bar==1.0 和 foo_bar==1.1,因为这些包版本存在依赖冲突。
ERROR: Cannot install Foo-Bar==1.0 and foo_bar==1.1 because these package versions have conflicting dependencies.
ID: python/pip-normalize-name-case-mismatch
80%修复率
87%置信度
0证据数
2025-03-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
两行依赖使用不同的名称拼写指定了同一个分发包;PEP 503 规范化将它们视为相同,因此固定两个版本会冲突。
English
Two requirement lines specify the same distribution using different name spellings; PEP 503 normalization treats them as equal, so pinning two versions conflicts.
解决方案
-
95% 成功率
python - <<'PY' from packaging.utils import canonicalize_name seen = {} for line in open('requirements.txt'): line = line.strip() if not line or line.startswith('#'): continue name = line.split('==')[0] canon = canonicalize_name(name) if canon in seen: print('duplicate:', line, 'vs', seen[canon]) else: seen[canon] = line PY -
98% 成功率
# requirements.txt foo-bar==1.1 # remove the duplicate foo_bar==1.0 line pip install -r requirements.txt
无效尝试
常见但无效的做法:
-
90% 失败
Skips dependency resolution but the two conflicting top-level pins still cannot coexist.
-
85% 失败
Force-reinstall does not reconcile versions; the resolver still reports the conflict.