handson-ml2 icon indicating copy to clipboard operation
handson-ml2 copied to clipboard

Downloading mnist data

Open qmemcm opened this issue 4 years ago • 3 comments

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 avatar Feb 02 '21 19:02 qmemcm

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?

qmemcm avatar Feb 05 '21 17:02 qmemcm

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.

ageron avatar Feb 18 '21 19:02 ageron

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

MPy2409 avatar Jun 12 '23 11:06 MPy2409