標籤:

國內pip源提示「not a trusted or secure host」解決方案

大家應該都知道怎麼添加國內pip源(主要是豆瓣和阿里雲),~/.pip/pip.conf文件配置大概如下(下面注釋掉了豆瓣源):

[global] # index-url = http://pypi.douban.com/simple index-url = http://mirrors.aliyun.com/pypi/simple/

但是現在最新的pip要求源必須是https的,不然會報錯:

The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with --trusted-host mirrors.aliyun.com.

但是每次要加這麼長的尾巴很不geek,嘗試在上面pip.conf裡面加上

trusted-host = mirrors.aliyun.com

居然好了,所以最終的pip.conf如下:

[global]index-url = http://mirrors.aliyun.com/pypi/simple/trusted-host = mirrors.aliyun.com

如果用豆瓣源,也是同理。

蒙對答案的感覺太好??

推薦閱讀:

TAG:Python | 鏡像 |