# ModuleNotFoundError：没有名为 'mypkg.data' 的模块
# 在从 sdist 执行 pip install mypkg 之后

- **ID:** `python/setuptools-sdist-missing-package-data`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

非 Python 数据文件或子包未包含在 sdist 中，因为 package_data/include_package_data 或 MANIFEST.in 配置错误。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   [tool.setuptools.package-data]
mypkg = ["data/*.json", "data/*.csv"]
# or
[tool.setuptools]
include-package-data = true
   ```
2. **** (90% 成功率)
   ```
   echo 'recursive-include mypkg/data *.json *.csv' >> MANIFEST.in
python -m build --sdist
pip install dist/mypkg-1.0.tar.gz
   ```

## 无效尝试

- **** — Forces building from sdist, which is exactly where the data files are missing. (90% 失败率)
- **** — Reinstall does not add missing files to the sdist. (85% 失败率)
- **** — .gitignore does not affect sdist contents; MANIFEST.in does. (80% 失败率)
