警告:位于 my.internal.pypi 的仓库不是受信任或安全的主机,已被忽略。如果该仓库可通过 HTTPS 访问,我们建议你改用 HTTPS,否则你可以通过 '--trusted-host my.internal.pypi' 消除此警告并允许它。 错误:找不到满足 internal-pkg 要求的版本
WARNING: The repository located at my.internal.pypi is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host my.internal.pypi'. ERROR: Could not find a version that satisfies the requirement internal-pkg
ID: python/pip-extra-index-not-trusted
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
| 3.10 | active | — | — | — |
| 3.11 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
pip 默认拒绝纯 HTTP 索引主机;通过 HTTP 提供的内部镜像被过滤掉,因此其包看起来不可用。
English
pip refuses plain HTTP index hosts by default; an internal mirror over HTTP is filtered out, so its packages appear unavailable.
解决方案
-
95% 成功率
pip config set global.index-url https://my.internal.pypi/simple pip install internal-pkg
-
90% 成功率
pip config set global.trusted-host my.internal.pypi pip config set global.extra-index-url http://my.internal.pypi/simple pip install internal-pkg
无效尝试
常见但无效的做法:
-
90% 失败
The internal package does not exist on public PyPI; the index-url override hides the internal mirror entirely.
-
90% 失败
DNS resolution is not the issue; pip's HTTP trust policy is.