I'm just starting to create an image classification program in Python with TensorFlow using the CIFAR10 dataset, following this tutorial. Here is my code so far:
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as plt
import numpy as np
datasets.cifar10.load_data()
I'm getting an error as follows:
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 1346, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1257, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1303, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1252, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1012, in _send_output
self.send(msg)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 952, in send
self.connect()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\http\client.py", line 1426, in connect
self.sock = self._context.wrap_socket(self.sock,
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)
What does this error mean, and what can I do to fix it? I'm a beginner with TensorFlow and haven't been able to find an exact solution for this issue.
Recently had a similar error using python 3.7
and just turned off the verification like this:
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as plt
import numpy as np
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
datasets.cifar10.load_data()
Check out this issue for more information. You can of course try to install the missing certificates for your Python version. I can confirm that your code works on Google Colab. So it is definitely due to some missing certificates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With