ageron / handson-ml2

A series of Jupyter notebooks that walk you through the fundamentals of Machine Learning and Deep Learning in Python using Scikit-Learn, Keras and TensorFlow 2.
Apache License 2.0
27.78k stars 12.73k forks source link

Downloading mnist data #377

Open qmemcm opened 3 years ago

qmemcm commented 3 years ago

Hi Aurélien: I am trying to download the mnist dataset as used in your book (chapter 3). I am using python version 3.8 and sklearn.version '0.24.0'

But I get this error:

from sklearn.datasets import fetch_openml
    ...: mnist = fetch_openml('mnist_784', version=1, cache=True)
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sklearn/datasets/_openml.py:65: RuntimeWarning: Invalid cache, redownloading file
  warn("Invalid cache, redownloading file", RuntimeWarning)
---------------------------------------------------------------------------
SSLCertVerificationError                  Traceback (most recent call last)

And then I am attaching the last line of this error:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)>

Any ideas what I am doing wrong? Thanks for your help!

qmemcm commented 3 years ago

I now realize that I get this error whenever I am using fetch_openml. So this example also gives me error: mice = fetch_openml(name='miceprotein', version=4)

This has something to do with the SSL error. How do I fix this?

ageron commented 3 years ago

Thanks for your question.

Generally, when people have SSL issues when using Python on MacOSX, it's due to a missing step when installing Python: installing the SSL certificates. You need to run this script :

/Applications/Python\ 3.8/Install\ Certificates.command

Also, I recommend you use Python 3.7 instead of Python 3.8, as some TensorFlow libraries don't support Python 3.8 yet.

Hope this helps.

MPy2409 commented 1 year ago

I had the same issue. I couldn't find Aurélien's script in my system, but Jia's answer from this thread worked for me: https://stackoverflow.com/questions/35569042/ssl-certificate-verify-failed-with-python3?rq=4