0

I was trying to import the CIFAR10 dataset in VS Code. However, an error pops up when trying to run the code. Please find below the attached code and output.

from torchvision import datasets
data_path= 'dataset_cifar/'
cifar10=datasets.CIFAR10(data_path,train=True,download=True)
cifar10_val=datasets.CIFAR10(data_path,train=False,download=True)

I get the following error.

    ---------------------------------------------------------------------------
SSLCertVerificationError                  Traceback (most recent call last)
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args)
   1345             try:
-> 1346                 h.request(req.get_method(), req.selector, req.data, headers,
   1347                           encode_chunked=req.has_header('Transfer-encoding'))

C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\http\client.py in request(self, method, url, body, headers, encode_chunked)
   1284         """Send a complete request to the server."""
-> 1285         self._send_request(method, url, body, headers, encode_chunked)
   1286 

C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1330             body = _encode(body, 'body')
-> 1331         self.endheaders(body, encode_chunked=encode_chunked)
   1332 

C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\http\client.py in endheaders(self, message_body, encode_chunked)
   1279             raise CannotSendHeader()
-> 1280         self._send_output(message_body, encode_chunked=encode_chunked)
   1281 

C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\http\client.py in _send_output(self, message_body, encode_chunked)
   1039         del self._buffer[:]
-> 1040         self.send(msg)
...
-> 1349                 raise URLError(err)
   1350             r = h.getresponse()
   1351         except:

URLError: 
  • Does this answer your question? [Python Requests throwing SSLError](https://stackoverflow.com/questions/10667960/python-requests-throwing-sslerror) – JialeDu Jul 07 '23 at 06:16
  • May I know what's going on with the problem? If it has been solved, can you change the status of the answer to help more people with similar problems. – JialeDu Jul 31 '23 at 02:10

1 Answers1

1

add this to your code to "workaround" the certification like

import ssl
ssl._create_default_https_context = ssl._create_unverified_context