1. 程式人生 > >Python3 解決pip報ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)

Python3 解決pip報ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)

Exception:
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 493, in urlopen
    body=body, headers=headers)
  File "C:\Python34\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 291, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Python34\lib\http\client.py", line 1090, in request
    self._send_request(method, url, body, headers)
  File "C:\Python34\lib\http\client.py", line 1128, in _send_request
    self.endheaders(body)
  File "C:\Python34\lib\http\client.py", line 1086, in endheaders
    self._send_output(message_body)
  File "C:\Python34\lib\http\client.py", line 924, in _send_output
    self.send(msg)
  File "C:\Python34\lib\http\client.py", line 859, in send
    self.connect()
  File "C:\Python34\lib\site-packages\pip\_vendor\requests\packages\urllib3\connection.py", line 190, in connect
    ssl_version=resolved_ssl_version)
  File "C:\Python34\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py", line 124, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Python34\lib\ssl.py", line 364, in wrap_socket
    _context=self)
  File "C:\Python34\lib\ssl.py", line 578, in __init__
    self.do_handshake()
  File "C:\Python34\lib\ssl.py", line 805, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)

 

本來打算用Python 載入openpyxl 模組來處理excel檔案~但是總是報SSL錯誤~
網友分析是沒辦法通過證書驗證,需要關閉證書驗證功能~~

先記錄Python3.4 自己實踐出來的修改方法:C:\Python34\Lib\site-packages\pip\_vendor\requests\adapters.py

304 行為我自己增加的設定

如日誌顯示,successfully installed openpyxl jdcal et-xmlfile

開啟Python  shell,測試import openpyxl,沒有報找不到模組如下為臨時讀取的Excel 中的資料,模組的函式都生效了

感謝一下兩位網友的分享~使得pip可以正常使用

https://blog.csdn.net/xfyangle/article/details/62052945

https://stackoverflow.com/questions/27499456/requests-s-geturl-verify-false-error-python

最後,該方法應該使用與Python3的所有版本,請熱心網友分享下結果,讓初學者更方便搞定環境,增加學習信心~~~

謝謝!