# ModuleNotFoundError：没有名为 'mypkg.subpkg' 的模块

- **ID:** `python/setuptools-find-packages-missing-subpackage`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

setuptools.find_packages() 未包含该子包，因为它缺少 __init__.py 或被排除模式过滤掉了。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   `touch mypkg/subpkg/__init__.py` then rebuild and reinstall the wheel.
   ```
2. **** (92% 成功率)
   ```
   In setup.py: `from setuptools import find_namespace_packages` then `packages=find_namespace_packages(include=['mypkg*'])`.
   ```

## 无效尝试

- **** — install_requires lists external deps, not local packages. (95% 失败率)
- **** — Breaks on upgrade and hides the packaging bug. (70% 失败率)
