python
config_error
ai_generated
true
ERROR: setuptools.errors.PackageDiscoveryError: Multiple top-level packages discovered in a flat-layout: ['mypackage', 'mypackage2']
ID: python/setuptools-package-dir-conflict
80%Fix Rate
85%Confidence
0Evidence
2024-10-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
Root Cause
Setuptools auto-discovery finds multiple packages in the root directory, causing ambiguity.
generic中文
Setuptools 自动发现功能在根目录中找到多个包,导致歧义。
Workarounds
-
95% success 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% success Use namespace packages if both are related
Rename packages to share a namespace like 'company.mypackage' and 'company.mypackage2'.
Dead Ends
Common approaches that don't work:
-
Renaming one package to a subpackage
70% fail
Does not resolve the discovery conflict; setuptools still sees two top-level packages.
-
Removing one package directory entirely
50% fail
Loss of code; better to configure explicitly.