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

其他格式: JSON · Markdown 中文 · English
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.

generic

官方文档

https://pip.pypa.io/en/stable/cli/pip_install/#install-trusted-host

解决方案

  1. 使用正确格式:--trusted-host example.com:8080(无 scheme,无尾部斜杠)
  2. 如果使用配置文件,在 pip.conf 或 pip.ini 中设置 trusted-host = example.com:8080
  3. 对于多个主机,重复该标志:--trusted-host host1 --trusted-host host2:443

无效尝试

常见但无效的做法:

  1. 80% 失败

    Pip expects only hostname:port, not a full URL; the scheme is implied.

  2. 60% 失败

    The parser strictly expects a hostname without path components.