How can I handle the error "certificate verify failed: certificate has expired" in TensorFlow?

Solution 1:

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.