Fix urlopen error EOF occurred in violation of protocol (_ssl.c:719) Error – Python Web Crawler Tutorial

By | August 28, 2019

<urlopen error EOF occurred in violation of protocol (_ssl.c:719)> occurs when you are using ssl in python application. In this tutorial, we will tell you why this error occur and how to fix it.

Why this error occur?

The main reason is the version of openssl is old.

import ssl
print (ssl.OPENSSL_VERSION)

The openssl version is:

OpenSSL 1.0.2k  26 Jan 2017

We should update openssl in python.

However, openssl is binded with python version. In python 3.5 we are using pyopenssl library to use openssl. It use OpenSSL 1.0.2k. To update OpenSSL, we also should update python.

Install python 3.7 with anaconda

To install python with conda, you can read this tutorial.

Install and Use Both Python 2 and Python 3 in Windows with Anaconda – Python Tutorial

You will find the intallation list.

python 3.7 openssl

From the list, we can view python 3.7 will use openssl 1.1.1.

Activate python 3.7 environment

activate py3.7

Install pyopenssl

pip install pyopenssl

Change Python Interpreters to python 3.7

python Interpreters to python 3.7

Run application again

The version of openssl will be:

OpenSSL 1.1.1b  26 Feb 2019

Then this error is fixed.

Leave a Reply