Solving Error when installing Python packages in Ubuntu – InsecurePlatformWarning, SSLError, tlsv1 alert protocol version

Error when installing Python packages in Ubuntu – InsecurePlatformWarning, SSLError, tlsv1 alert protocol version is an error which occurs because of a faulty OpenSSL installation.

This post is my attempt to explain to you why this error occurs and how you can solve it, I will also include multiple solutions that could be considered as alternative fixes to the error.

Explaining the Error when installing Python packages in Ubuntu – InsecurePlatformWarning, SSLError, tlsv1 alert protocol version

The error can happen to anyone with a faulty OpenSSL installation.

Make sure your error message looks similar to this one.

                                                                       #
/home/teleduce/.virtualenvs/teleduce_handler/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an 
.....
SNIMissingWarning
 /home/teleduce/.virtualenvs/teleduce_handler/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning:  routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version - skipping
                                                                       #

Bellow I make my best attempt at solving the error and present the best possible solution I could find.

Solution : install OpenSSL and dependecies.

First, it is important to understand that the SSLError happens because the version of system OpenSSL library is not compatible with PyPI (the Python Package Index ) used by pip.

We can only solve this issue by installing relevant packages manually, we cannot use pip to solve this issue.

First, go to the link bellow.

                                                                       #
pypi.org
                                                                       #

Then, download these packages while choosing the recent .whl for your platform or OS.

Bellow is a list of the packages.

pyOpenSSL, asn1crypto, idna, enum34, cryptography wheels, six, ipaddress, pip, cffi, pycparser (tar.gz).

Then, create a new directory.

                                                                       #
mkdir ~/wheels_dir
                                                                       #

After you download all the packages, move them to the directory above. The directory should have no subdirectories and should only contain wheel files.

Now, run the command bellow.

                                                                       #
pip install --user --no-index ~/wheels_dir/pip-19.0.1-py2.py3-none-any.whl
                                                                       #

Then, run this one.

                                                                       #
pip install --user --no-index ~/wheels_dir/*
                                                                       #

Then,

                                                                       #
pip3 in Python 3
                                                                       #

Followed by this command.

                                                                       #
source bin/activate
                                                                       #

And finally.

                                                                       #
pip install --no-index ~/wheels_dir/*
                                                                       #

You can use this to verify.

                                                                       #
python -m OpenSSL.debug
                                                                       #

I hope the commands above fixed your problem, good luck with the scripts to come.

I hope this blog post solved your issue, thank you for reading.

you can support us by donating to our Kofi account, this website is free to use but any help is very appreciated and goes a long way.

Summing-up

Here we are at the end of the road, at the end of this article, if you solved this error congrats, this was a confusing error for me the first time I encountered it.

Make sure to keep coding and keep learning, Python is my favourite programming language, it just needs some patience, cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/