Python pip install之SSL異常處理操作
異常內(nèi)容:
C:\Users\ccwant>pip install requests
Collecting requests
Retrying (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)'),)) - skipping
Could not find a version that satisfies the requirement requests (from versions: )
No matching distribution found for requests
處理辦法:
打開以下目錄,并創(chuàng)建pip文件夾
C:\Users\用戶\AppData\Roaming
進(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安裝就不會報錯了
補充知識:處理Python3中使用pip install時提示"SSL: CERTIFICATE_VERIFY_FAILED"
CentOS7使用官方y(tǒng)um源安裝了Python3和pip(yum搜不到python3的話請安裝epel-release)
[root@client0 yum.repos.d]# python3 --version
Python 3.6.8
[root@client0 yum.repos.d]# pip3 --version
pip 8.1.2 from /usr/lib/python3.6/site-packages (python 3.6)
使用pip安裝包時會提示你pip版本過低, 建議使用pip install --upgrade pip命令來升級.
而使用該命令時則會彈出一連串錯誤提示, 其中包含關(guān)鍵字"SSL: CERTIFICATE_VERIFY_FAILED"
這時的處理辦法是跳過pip的SSL驗證
使用命令
pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name>
即可.
以上這篇Python pip install之SSL異常處理操作就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
使用scipy.optimize的fsolve,root函數(shù)求解非線性方程問題
這篇文章主要介紹了使用scipy.optimize的fsolve,root函數(shù)求解非線性方程問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-12-12
Python中微服務(wù)架構(gòu)的設(shè)計與實現(xiàn)詳解
在當(dāng)今軟件開發(fā)領(lǐng)域中,微服務(wù)架構(gòu)已經(jīng)成為了一種流行的設(shè)計范式,這篇文章主要為大家介紹了如何使用Python語言來設(shè)計和實現(xiàn)微服務(wù)架構(gòu),需要的可以參考一下2024-04-04
教你用Type Hint提高Python程序開發(fā)效率
本文通過介紹和實例教大家如何利用Type Hint來提升Python程序開發(fā)效率,對大家使用python開發(fā)很有幫助,有需要的參考學(xué)習(xí)。2016-08-08
pandas中.loc和.iloc以及.at和.iat的區(qū)別說明
這篇文章主要介紹了pandas中.loc和.iloc以及.at和.iat的區(qū)別說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-04-04

