Python pip install之SSL異常處理操作
異常內(nèi)容:
C:Usersccwant>pip install requestsCollecting requestsRetrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ’SSLError(SSLError(1, ’[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)’),)’: /simple/requests/Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ’SSLError(SSLError(1, ’[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)’),)’: /simple/requests/Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ’SSLError(SSLError(1, ’[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)’),)’: /simple/requests/Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ’SSLError(SSLError(1, ’[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)’),)’: /simple/requests/Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ’SSLError(SSLError(1, ’[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)’),)’: /simple/requests/Could not fetch URL https://pypi.org/simple/requests/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=’pypi.org’, port=443): Max retries exceeded with url: /simple/requests/ (Caused by SSLError(SSLError(1, ’[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)’),)) - skippingCould not find a version that satisfies the requirement requests (from versions: )No matching distribution found for requests
處理辦法:
打開(kāi)以下目錄,并創(chuàng)建pip文件夾
C:Users用戶AppDataRoaming
進(jìn)入pip文件夾,創(chuàng)建pip.ini文件,內(nèi)容如下
[global]index-url = http://mirrors.aliyun.com/pypi/simple/[install]trusted-host = mirrors.aliyun.com
此配置的作用是修改pip的安裝源,此處修改為阿里的源,然后使用pip install安裝就不會(huì)報(bào)錯(cuò)了
補(bǔ)充知識(shí):處理Python3中使用pip install時(shí)提示'SSL: CERTIFICATE_VERIFY_FAILED'
CentOS7使用官方y(tǒng)um源安裝了Python3和pip(yum搜不到python3的話請(qǐng)安裝epel-release)
[root@client0 yum.repos.d]# python3 --versionPython 3.6.8[root@client0 yum.repos.d]# pip3 --versionpip 8.1.2 from /usr/lib/python3.6/site-packages (python 3.6)
使用pip安裝包時(shí)會(huì)提示你pip版本過(guò)低, 建議使用pip install --upgrade pip命令來(lái)升級(jí).
而使用該命令時(shí)則會(huì)彈出一連串錯(cuò)誤提示, 其中包含關(guān)鍵字'SSL: CERTIFICATE_VERIFY_FAILED'
這時(shí)的處理辦法是跳過(guò)pip的SSL驗(yàn)證
使用命令
pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>
即可.
以上這篇Python pip install之SSL異常處理操作就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. javascript xml xsl取值及數(shù)據(jù)修改第1/2頁(yè)2. 利用CSS制作3D動(dòng)畫3. Properties 持久的屬性集的實(shí)例詳解4. jsp文件下載功能實(shí)現(xiàn)代碼5. XML入門的常見(jiàn)問(wèn)題(四)6. WML語(yǔ)言的基本情況7. php網(wǎng)絡(luò)安全中命令執(zhí)行漏洞的產(chǎn)生及本質(zhì)探究8. ASP基礎(chǔ)入門第八篇(ASP內(nèi)建對(duì)象Application和Session)9. HTML5 Canvas繪制圖形從入門到精通10. CSS代碼檢查工具stylelint的使用方法詳解
