I am using Keras
and trying to load mnist
dataset.
Link to the website is: https://s3.amazonaws.com/img-datasets/mnist.pkl.gz
It works in a browser. But when I call 'mnist.load_data()', I get the exception:
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:645)
There are many solutions already provided, I tried almost all of them.
Below is the stacktrace:
Downloading data from https://s3.amazonaws.com/img-datasets/mnist.pkl.gz
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.5/urllib/request.py", line 1684, in open
return getattr(self, name)(url)
File "/home/user/anaconda3/lib/python3.5/urllib/request.py", line 1894, in open_https
return self._open_generic_http(self._https_connection, url, data)
File "/home/user/anaconda3/lib/python3.5/urllib/request.py", line 1843, in _open_generic_http
http_conn.request("GET", selector, headers=headers)
File "/home/user/anaconda3/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/home/user/anaconda3/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/home/user/anaconda3/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
File "/home/user/anaconda3/lib/python3.5/http/client.py", line 911, in _send_output
self.send(msg)
File "/home/user/anaconda3/lib/python3.5/http/client.py", line 854, in send
self.connect()
File "/home/user/anaconda3/lib/python3.5/http/client.py", line 1237, in connect
server_hostname=server_hostname)
File "/home/user/anaconda3/lib/python3.5/ssl.py", line 376, in wrap_socket
_context=self)
File "/home/user/anaconda3/lib/python3.5/ssl.py", line 747, in __init__
self.do_handshake()
File "/home/user/anaconda3/lib/python3.5/ssl.py", line 983, in do_handshake
self._sslobj.do_handshake()
File "/home/user/anaconda3/lib/python3.5/ssl.py", line 628, in do_handshake
self._sslobj.do_handshake()
My 'openssl version' on console yeilds:
openssl version
OpenSSL 1.0.2e 3 Dec 2015
In python console:
>>> import OpenSSL
>>> OpenSSL.__version__
'0.15.1'
>>> import ssl
>>> print (ssl.OPENSSL_VERSION)
OpenSSL 1.0.2e 3 Dec 2015
I am using Python 3.5 that came with anaconda
I also upgraded OpenSSL using conda install OpenSSL
but the error persists.
I also tried a patch:
import ssl
from functools import wraps
def sslwrap(func):
@wraps(func)
def bar(*args, **kw):
kw['ssl_version'] = ssl.PROTOCOL_TLSv1
return func(*args, **kw)
return bar
ssl.wrap_socket = sslwrap(ssl.wrap_socket)
But still no resolution. How can I get rid of this error?