# 错误：在扁平布局中发现了多个顶级包：['pkg1', 'pkg2']。

- **ID:** `python/setuptools-find-packages-no-init`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用find_packages()而未指定where时，setuptools检测到当前目录中的多个顶级包，这是不明确的，不允许。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Specify the source directory: `packages=find_packages(where='src')` and move packages to src/ layout.
   ```
2. **** (95% 成功率)
   ```
   Explicitly list packages: `packages=['pkg1', 'pkg2']` in setup.py.
   ```
3. **** (80% 成功率)
   ```
   Use `find_namespace_packages()` for namespace packages if applicable.
   ```

## 无效尝试

- **** — This is not practical if both packages are needed; and the error is about configuration, not about having multiple packages. (40% 失败率)
- **** — This will cause no packages to be installed, defeating the purpose. (90% 失败率)
- **** — This still leaves pkg2 undiscovered and may not include all needed modules. (50% 失败率)
