# 错误：无效的命令类 'foo.bar'  # 来自 [options.entry_points] 或未知的 setup.cfg 键

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

## 根因

setup.cfg 的某个节或键拼写错误，或不被已安装的 setuptools 版本支持（如用旧版 setuptools 使用新版才有的键），因此 setuptools 将其视为无效命令。

## 版本兼容性

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

## 解决方案

1. **** (85% 成功率)
   ```
   Upgrade setuptools to one that supports the key: python -m pip install --upgrade setuptools  # then rebuild
   ```
2. **** (78% 成功率)
   ```
   Validate the config: python -c "import configparser; c=configparser.ConfigParser(); c.read('setup.cfg'); print(c.sections())"  # compare keys against setuptools docs
   ```

## 无效尝试

- **** — Disabling isolation doesn't fix an unknown config key; the same invalid command error is raised by the local setuptools. (60% 失败率)
- **** — Removes all metadata and entry points, causing a different failure (missing name/version) instead of fixing the key. (75% 失败率)
