错误【ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed...】

Downloading: "https://download.pytorch.org/models/resnet50-19c8e357.pth" to /home/luanhaijing/.cache/torch/hub/checkpoints/resnet50-19c8e357.pth
Traceback (most recent call last):
  File "/data/luanhaijing/project/Ltoad_env/lib/python3.7/urllib/request.py", line 1319, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/data/luanhaijing/project/Ltoad_env/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/data/luanhaijing/project/Ltoad_env/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/data/luanhaijing/project/Ltoad_env/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/data/luanhaijing/project/Ltoad_env/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/data/luanhaijing/project/Ltoad_env/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/data/luanhaijing/project/Ltoad_env/lib/python3.7/http/client.py", line 1422, in connect
    server_hostname=server_hostname)
  File "/data/luanhaijing/project/Ltoad_env/lib/python3.7/ssl.py", line 423, in wrap_socket
    session=session
  File "/data/luanhaijing/project/Ltoad_env/lib/python3.7/ssl.py", line 870, in _create
    self.do_handshake()
  File "/data/luanhaijing/project/Ltoad_env/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:1076)

解决办法:只需要将其中的https换成http即可成功解决

除此之外,如果没有出现明确的http地址的情况下,需要
在这里插入图片描述
上述的解决办法会不再适用,会出现如下的问题

# 全局取消证书验证
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值