0, problem description
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 it anyway with ' --trusted-host mirrors.tencentyun.com'.
1. Solution
This problem occurs because some domestic sources and intranet sources are not configured with HTTPS. Use the following methods to ignore them. Here, Tencent Cloud intranet sources are used. If you use other sources, remember to replace the URL.
Take updating pip as an example, the original command:
1 | pip3 install --upgrade pip |
Temporary solution:
1 | pip3 install --upgrade pip --trusted-host mirrors.tencentyun.com |
Write to .bashrc
:
1 | echo "alias pip='pip --trusted-host mirrors.tencentyun.com'" >> ~/.bashrc echo "alias pip3='pip3 --trusted-host mirrors.tencentyun.com'" >> ~/.bashrc source ~/.bashrc |
This is automatically ignored when executed on the command line.
Write configuration file:
In /root/.config/pip/pip.conf
, the original content is:
1 | [global] index-url = http://mirrors.tencentyun.com/pypi/simple |
Change to:
[hide]
1 | [global] index-url = http://mirrors.tencentyun.com/pypi/simple [install] trusted-host=mirrors.tencentyun.com |
[hide]
Notice:
There are some weird tutorials that will teach you to use:
1 | pip config set global.trusted-host mirrors.tencentyun.com |
In fact, this is wrong, because the configuration item is set in the wrong place, so be careful not to be misled.
Fix pip Warning : Mirror Source is Unsafe
Comments