python使用pip安裝模組出錯 Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None))
阿新 • • 發佈:2018-12-26
問題:在使用python時,使用pip安裝psutil出錯(pip install psutil),錯誤資訊:
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAI LED] certificate verify failed (_ssl.c:726)'),)': /packages/0f/fb/6aecd2c8c9d0ac 83d789eaf9f9ec052dd61dd5aea2b47ffa4704175d7a2a/psutil-5.4.8-cp27-none-win_amd64. whl
解決方法:出現該錯誤資訊是因為pip源連線證書驗證失敗,將pip源調整為國內的源就可以了,比如要下載psutil
pip install psutil -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
下面是收集的一些國內的pip源:
阿里雲 http://mirrors.aliyun.com/pypi/simple/ 中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/ 中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
如果想要永久修改pip源,可按照如下操作:
Windows:
-
找到系統盤下C:\C:\Users\使用者名稱\AppData\Roaming
-
檢視在Roaming資料夾下有沒有一個pip資料夾,如果沒有建立一個;
-
進入pip資料夾,建立一個pip.ini檔案;
-
使用記事本的方式開啟pip.ini檔案,寫入:
[global] index-url = http://mirrors.aliyun.com/pypi/simple # 指定下載源 trusted-host = mirrors.aliyun.com # 指定域名
Linux:
# 找到~/.pip/pip.conf,如果不存在就建立,加入內容如下
[global] timeout = 10 # 設定超時,單位s index-url = http://mirrors.aliyun.com/pypi/simple/ # 指定優先下載源 extra-index-url= http://pypi.douban.com/simple/ # 第二下載源 [install] trusted-host= mirrors.aliyun.com pypi.douban.com