python
config_error
ai_generated
true
错误:setuptools.errors.PackageDiscoveryError:在扁平布局中发现多个顶级包:['mypackage', 'mypackage2']
ERROR: setuptools.errors.PackageDiscoveryError: Multiple top-level packages discovered in a flat-layout: ['mypackage', 'mypackage2']
ID: python/setuptools-package-dir-conflict
80%修复率
85%置信度
0证据数
2024-10-01首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
根因分析
Setuptools 自动发现功能在根目录中找到多个包,导致歧义。
English
Setuptools auto-discovery finds multiple packages in the root directory, causing ambiguity.
解决方案
-
95% 成功率 Explicitly specify packages in setup.cfg or setup.py
In setup.cfg: [options] packages = find: find: include = mypackage* Or in setup.py: packages=['mypackage']
-
85% 成功率 Use namespace packages if both are related
Rename packages to share a namespace like 'company.mypackage' and 'company.mypackage2'.
无效尝试
常见但无效的做法:
-
Renaming one package to a subpackage
70% 失败
Does not resolve the discovery conflict; setuptools still sees two top-level packages.
-
Removing one package directory entirely
50% 失败
Loss of code; better to configure explicitly.