Pycharm 用pip命令安裝第三方包出現retrying且ssl error問題彙總

今天pip包時一直retrying且報ssl error的錯誤,我弄了一上午纔好,網上有很多解決方案,但是沒有pip安裝失敗的彙總情況,如有同錯,請對比以下情況,希望能解決你的問題,也煩請對不足之處指出。

一、

錯誤:CouldnotfetchURLhttps://pypi.python.org/simple/pytest-xdist/: There wasaproblem confirmingthessl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocolversion(_ssl.c:590)

 

原因:python.org已經不支持TLSv1.0和TLSv1.1,需要升級pip,但是pip用不了,所以手動升級

 

解決方案:

1.mac或者linux操作系統:在終端下執行命令:

curl https://bootstrap.pypa.io/get-pip.py | python3。

 

 

 

2.windows操作系統:從https://bootstrap.pypa.io/get-pip.py下載get-pip.py文件,然後使用python運行這個文件python get-pip.py

 

二、

錯誤:Retrying (Retry(total=4, 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:661)'),)'

 

原因:可能用國外鏡像源連接不好

 

解決方案:

1.mac或者linux操作系統:

修改 ~/.pip/pip.conf (沒有就創建一個), 更換 index-url

 

[global]

index-url = http://pypi.douban.com/simple

2.windows操作系統:

直接在user目錄中創建一個pip目錄,如:C:\Users\xx\pip,新建文件pip.ini,內容同上

附:鏡像源

阿里雲 http://mirrors.aliyun.com/pypi/simple/

中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣 http://pypi.douban.com/simple

Python官方 https://pypi.python.org/simple/

v2ex http://pypi.v2ex.com/simple/

中國科學院 http://pypi.mirrors.opencas.cn/simple/

清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/

 

三、

錯誤:Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by S

SLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)) - skipping

 

原因:在最新的 pip 版本(>=7)中,使用鏡像源時,會提示源地址不受信任或不安全

 

解決方案1:

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org 包名

 

解決方案2:(推薦)

在第二個解決方案中:添加一項配置

[install]

trusted-host=http://pypi.douban.com/simple




轉載:https://www.jianshu.com/p/6f6c640b0371
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章