0、问题描述
WARNING: The repository located at mirrors.tencentyun.com 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 i t anyway with '--trusted-host mirrors.tencentyun.com'.
1、解决方法
出现这个问题是因为部分国内源和内网源没有配置 HTTPS,使用以下方法忽略即可,这里使用的是腾讯云内网源,如果你使用其他源记得替换 URL。
以更新 pip 为例,原始命令:
1 | pip3 install --upgrade pip |
临时解决:
1 | pip3 install --upgrade pip --trusted-host mirrors.tencentyun.com |
写入.bashrc
:
1 | echo "alias pip='pip --trusted-host mirrors.tencentyun.com'" >> ~/.bashrc echo "alias pip3='pip3 --trusted-host mirrors.tencentyun.com'" >> ~/.bashrc source ~/.bashrc |
这样在命令行执行时会自动忽略。
写入配置文件:
在/root/.config/pip/pip.conf
,原内容为:
1 | [global] index-url = http://mirrors.tencentyun.com/pypi/simple |
改为:
[hide]
1 | [global] index-url = http://mirrors.tencentyun.com/pypi/simple [install] trusted-host = mirrors.tencentyun.com |
[hide]
注意:
有一些莫名其妙的教程会教你使用:
1 | pip config set global.trusted-host mirrors.tencentyun.com |
事实上这是错的,因为配置项设置错了地方,注意不要被误导了。
解决 pip 提示镜像源不安全
评论