Error - urlopen error [Errno 8] _ssl.c:504: EOF occurred in violation of protocol Error - urlopen error [Errno 8] _ssl.c:504: EOF occurred in violation of protocol python python

Error - urlopen error [Errno 8] _ssl.c:504: EOF occurred in violation of protocol


Instead of copying and editing Python library modules, you can monkey-patch ssl.wrap_socket() in the ssl module by overriding the ssl_version keyword parameter. The following code can be used as-is. Put this at the start of your program before making any requests.

import sslfrom functools import wrapsdef sslwrap(func):    @wraps(func)    def bar(*args, **kw):        kw['ssl_version'] = ssl.PROTOCOL_TLSv1        return func(*args, **kw)    return barssl.wrap_socket = sslwrap(ssl.wrap_socket)


Its a known bug, how ever some solutions for it are mentioned in the comments of this link. See them , May be helpful to you, bug url.