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