当前位置:   article > 正文

解决python报错[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:_biopython sslcertivicationerror

biopython sslcertivicationerror
>>> model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
Traceback (most recent call last):
  File "/myconda/envs/py37/lib/python3.7/urllib/request.py", line 1350, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/myconda/envs/py37/lib/python3.7/http/client.py", line 1277, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/myconda/envs/py37/lib/python3.7/http/client.py", line 1323, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/myconda/envs/py37/lib/python3.7/http/client.py", line 1272, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/myconda/envs/py37/lib/python3.7/http/client.py", line 1032, in _send_output
    self.send(msg)
  File "/myconda/envs/py37/lib/python3.7/http/client.py", line 972, in send
    self.connect()
  File "/myconda/envs/py37/lib/python3.7/http/client.py", line 1447, in connect
    server_hostname=server_hostname)
  File "/myconda/envs/py37/lib/python3.7/ssl.py", line 423, in wrap_socket
    session=session
  File "/myconda/envs/py37/lib/python3.7/ssl.py", line 870, in _create
    self.do_handshake()
  File "/myconda/envs/py37/lib/python3.7/ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

这个错误经常发生在在线下载代码, 模型文件或数据的时候。发生这个错误的原因是没有正确配置网络的证书相关的东西。

解决办法: 全局取消证书验证

import ssl
ssl._create_default_https_context = ssl._create_unverified_context
  • 1
  • 2

参考:
https://www.jianshu.com/p/7d8eee279e7d

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/564570
推荐阅读
相关标签
  

闽ICP备14008679号