python module_error ai_generated true

ModuleNotFoundError: No module named 'mypkg.subpkg'

ID: python/setuptools-find-packages-missing-subpackage

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-04-11First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
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

  1. 95% success
    `touch mypkg/subpkg/__init__.py` then rebuild and reinstall the wheel.
  2. 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:

  1. 95% fail

    install_requires lists external deps, not local packages.

  2. 70% fail

    Breaks on upgrade and hides the packaging bug.