# ConfigParser.MissingSectionHeaderError: 文件不包含节标题。
文件：setup.cfg，第1行
'[metadata]\n'

- **ID:** `python/setuptools-setup-cfg-parse-error`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

setup.cfg 文件格式错误，开头缺少节标题或编码不正确。

## 版本兼容性

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

## 解决方案

1. **Ensure the first line is a valid section header like [metadata] or [options]** (95% 成功率)
   ```
   Edit setup.cfg so that line 1 is exactly '[metadata]' without leading spaces.
   ```
2. **Use UTF-8 encoding and no BOM** (90% 成功率)
   ```
   Re-save the file as UTF-8 without BOM using a text editor like VS Code or Notepad++.
   ```

## 无效尝试

- **Adding extra blank lines before [metadata]** — The parser expects the first non-empty line to be a section header. (85% 失败率)
- **Changing file extension to .txt** — setuptools specifically looks for setup.cfg; renaming breaks detection. (90% 失败率)
