MNIST handwritten data collection solutions to problems in the operation

  Today, during the operation of the handwritten data set, there is a problem, the code is no problem, but when the run has been given the wrong follows:

urllib.error.URLError: <urlopen error [SSL:


CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c: 1051)>   query various online blog or something, and finally looks like because of the emergence of python3 , the solution is currently used at the top of the code add the following code that few now can be a good solution
import requests
requests.packages.urllib3.disable_warnings()
import ssl

try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    # Legacy Python that doesn't verify HTTPS certificates by default
    pass
else:
# Handle target environment that doesn't support HTTPS verification
    ssl._create_default_https_context = _create_unverified_https_context

 Reference pages are as follows:

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000117730-SSL-error-in-accessing-MNIST-dataset



Guess you like

Origin www.cnblogs.com/goulingyun/p/11704616.html