python
config_error
ai_generated
true
error: Multiple top-level packages discovered in a flat-layout: ['pkg1', 'pkg2'].
ID: python/setuptools-find-packages-no-init
80%Fix Rate
84%Confidence
0Evidence
2024-06-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
Root Cause
When using find_packages() without specifying where, setuptools detects multiple top-level packages in the current directory, which is ambiguous and not allowed.
generic中文
使用find_packages()而未指定where时,setuptools检测到当前目录中的多个顶级包,这是不明确的,不允许。
Workarounds
-
90% success
Specify the source directory: `packages=find_packages(where='src')` and move packages to src/ layout.
-
95% success
Explicitly list packages: `packages=['pkg1', 'pkg2']` in setup.py.
-
80% success
Use `find_namespace_packages()` for namespace packages if applicable.
Dead Ends
Common approaches that don't work:
-
40% fail
This is not practical if both packages are needed; and the error is about configuration, not about having multiple packages.
-
90% fail
This will cause no packages to be installed, defeating the purpose.
-
50% fail
This still leaves pkg2 undiscovered and may not include all needed modules.