ERROR
pip
config_error
ai_generated
true
错误:'--trusted-host' 的值无效:'example.com:8080' 不符合预期模式。期望主机名或 IP 地址,可选带端口。
ERROR: Invalid value for '--trusted-host': 'example.com:8080' does not match expected pattern. Expected a hostname or IP address, optionally with a port.
ID: pip/trusted-host-flag-misuse
95%修复率
90%置信度
1证据数
2024-01-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| pip 23.3 | active | — | — | — |
| pip 24.0 | active | — | — | — |
| pip 24.1 | active | — | — | — |
根因分析
--trusted-host 标志传递的值格式不正确,例如带有 scheme 的 URL(https://...)或无效的端口分隔符,pip 无法解析以用于其受信任主机逻辑。
English
The --trusted-host flag was passed a value with an incorrect format, such as a URL with scheme (https://...) or an invalid port separator, which pip cannot parse for its trusted host logic.
官方文档
https://pip.pypa.io/en/stable/cli/pip_install/#install-trusted-host解决方案
-
使用正确格式:--trusted-host example.com:8080(无 scheme,无尾部斜杠)
-
如果使用配置文件,在 pip.conf 或 pip.ini 中设置 trusted-host = example.com:8080
-
对于多个主机,重复该标志:--trusted-host host1 --trusted-host host2:443
无效尝试
常见但无效的做法:
-
80% 失败
Pip expects only hostname:port, not a full URL; the scheme is implied.
-
60% 失败
The parser strictly expects a hostname without path components.