# 错误：pip.conf 文件中不允许使用选项 '--trusted-host'。请使用格式：trusted-host = pypi.org
files.pythonhosted.org

- **ID:** `pip/pip-conf-option-error`
- **领域:** pip
- **类别:** config_error
- **错误码:** `ERROR`
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

pip 配置文件（pip.conf/pip.ini）包含命令行样式的选项（如 --trusted-host），而不是正确的 INI 风格键值对格式。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 22.3 | active | — | — |
| pip 23.0 | active | — | — |
| pip 23.2 | active | — | — |

## 解决方案

1. ```
   Edit pip.conf to use correct INI format:
[global]
trusted-host = pypi.org
files.pythonhosted.org
   ```
2. ```
   Remove the offending lines and use environment variables instead: export PIP_TRUSTED_HOST="pypi.org files.pythonhosted.org"
   ```
3. ```
   Validate config with: pip config list --global (or --user/--site) to see current effective settings.
   ```

## 无效尝试

- **** — This works temporarily but does not fix the config file; the error persists on next pip command reading the config. (70% 失败率)
- **** — Still uses the CLI-style prefix; config expects bare key names without dashes. (90% 失败率)
- **** — Removes the error but also removes all other valid configurations, potentially breaking other settings. (50% 失败率)
