python
module_error
ai_generated
true
ModuleNotFoundError: No module named 'mypkg.subpkg'
ID: python/setuptools-find-packages-missing-subpackage
80%Fix Rate
87%Confidence
0Evidence
2024-04-11First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
setuptools.find_packages() did not include the subpackage because it lacks an __init__.py or was excluded by patterns.
generic中文
setuptools.find_packages() 未包含该子包,因为它缺少 __init__.py 或被排除模式过滤掉了。
Workarounds
-
95% success
`touch mypkg/subpkg/__init__.py` then rebuild and reinstall the wheel.
-
92% success
In setup.py: `from setuptools import find_namespace_packages` then `packages=find_namespace_packages(include=['mypkg*'])`.
Dead Ends
Common approaches that don't work:
-
95% fail
install_requires lists external deps, not local packages.
-
70% fail
Breaks on upgrade and hides the packaging bug.