今天在安裝一個第三方庫時報(bào)如下錯誤
pip install --upgrade baostock
Could not fetch URL https://pypi.org/simple/baostock/: There was a problem confi
rming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max r
etries exceeded with url: /simple/baostock/ (Caused by SSLError(SSLCertVerificat
ionError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self si
gned certificate in certificate chain (_ssl.c:1045)'))) - skipping
當(dāng)前python版本是3.7,網(wǎng)上查找說是python高版本需要驗(yàn)證ssl赤炒,可以添加--trusted-host domain來解決伍纫,于是趕緊嘗試一下
pip install --trusted-host pypi.org --upgrade baostock
又報(bào)如下錯誤
Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host=
'files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/57
/f8/e909079851f6ea6685bb63ea143c66a0f4141fc3ce17e728ec908819ed54/baostock-0.8.5-
py3-none-any.whl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFIC
ATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certifi
cate chain (_ssl.c:1045)')))
原來是另一個域名files.pythonhosted.org也是https的拒迅,也需要指定為trusted-host才可以,問題是同時指定兩個域名為trusted-host該怎么寫呢哆料?網(wǎng)上找了半天沒找到,經(jīng)過自己一番摸索,發(fā)現(xiàn)如下的寫法可以
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org? --upgrade? baostock
如果是兩個以上的域名以此類推龙宏,貢獻(xiàn)給大家,希望對遇到同樣問題的同學(xué)有所幫助伤疙。