Insecureplatformwarning: a True Sslcontext Object Is Not Available. This Prevents Urllib3 from Configuring Ssl Appropriately

Cannot pip install with python 2,7 virtual environment

For anyone who stumbles upon this in the future, ocropy needs Python 2.7 but numpy and scipy newest versions dropped Python 2.7 support. However, you can still use them but the problem is that our developer folks will stop supporting bug fixes.

My problem was mainly the global version of Python I have on my system (windows) is 3.6.7 while ocropus requires 2.7. I downloaded a broken executable for Python 2.7 that did not have the Scripts folder installed, thus pip ended up not working at all.

Followed this tutorial that shows how to install another version of python (2.7) and the problem was solved when I downloaded the following executable

In order to use thevirtualenv properly with python 2.7 use the following command

# dont forget to add python.exe 
virtualenv -p C:\Python27\python.exe venv/ocropus

Goodluck.

Python PIP and InsecurePlatformWarning

Indeed, as of 2019, quite a few people are still facing this issue, as they cannot upgrade their system Python (and system-supplied openssl) due to various limitations.

If you'd like to fix the InsecurePlatformWarning .. (Caused by SSLError .. SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'), the following solution can help someone using an old Linux distro:

Unable to install Python packages using pip in Ubuntu Linux: InsecurePlatformWarning, SSLError, tlsv1 alert protocol version

Python 2.6.6 on CentOS6

In your specific case, the last cryptography version to officially support Python 2.6 was cryptography-2.1.1, although a newer version might work.
The first manylinux1 cryptography package to include its own OpenSSL (1.1.0f) shared lib binding for Linux, regardless of what's on your platform, has appeared in cryptography-2.0 version. The last cryptography that still officially supported Centos 6.4 was version 1.8.2, while newer versions officially supported CentOS 7.x only: https://pypi.org/project/cryptography/#files

Note, cryptography versions<2.0 have no manylinux1 and didn't ship the openssl/ssllib with them, relying on the system-supplied one only (back then, they did so only for other OSes that had/have even bigger SSL problems). While the cryptography-2.0 (manylinux1) is still worth trying, you will probably have to compile the newer openssl version (1.0.1 - 1.1.0) locally on Centos 6.x, before compiling cryptography 1.8.2 to link against it:

https://cryptography.io/en/latest/installation/#using-your-own-openssl-on-linux

https://cryptography.io/en/latest/installation/#rhel-centos

There is also an option to build your own statically-linked wheels that will work on your own systems:

https://cryptography.io/en/latest/installation/#static-wheels

That said,

if all you needed was just to install the requests lib (without solving the notorious SSLError), specifically in Python 2.6.6 on CentOS6, and you are not going to need TLS 1.2 protocol support from requests, you could simply use your Centos repo for that:

$ yum search requests
$ sudo yum install python26-requests

Or, you could get and install requests in a similar way as in the above-mentioned solution, from wheels or from tar.gz downloaded from:
https://pypi.org/project/requests/

Note, the latest requests on PyPI depends on the following Python packages:
urllib3, idna, chardet, certifi

Luckily, these four have no other dependencies and can be obtained from PyPI directly, in the same way - the "Download Files" section on PyPI:

https://pypi.org/project/urllib3/

https://pypi.org/project/idna/

https://pypi.org/project/chardet/

https://pypi.org/project/certifi/

You could download and try to install their latest versions, or use 'Release History' section to locate older versions, depending on your use-case and system-specific requirements.

Note, many web servers (including PyPI) nowadays require TLS 1.2 support, both in the client and server backend, to establish an HTTPS connection, so if you will need this type of connections, requests will not work without fixing the SSLError the way discussed above (or by compiling a newer Python 2.7.9+ against OpenSSL version 1.0.2+ that would have to be compiled as well in that case, before compiling new Python, to link ssl module with it).

InsecurePlatformWarning: A true SSLContext object is not available

Try installing the packages one by one from requirements.txt and when you find the one that is throwing this error, try to look for a solution for that specific package.

How can I fix pip install certificate issue on Windows with Python 2.7?

See this line in your error:

routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)': 

Python.org sites have recently stopped support for TLS v1.0 and v1.1

Try upgrading pip as follows:

curl https://bootstrap.pypa.io/get-pip.py | python

You can still use Python 2.7 once you upgrade pip since it will then use the later TLS version (i.e >=1.2)

See this answer for more details.

python InsecurePlatformWarning when downloading pip on Windows (python 2.7.5)

You can upgrade to a newer version of Python to solve this.

So to answer your question: Yes, get a new version of python. According to the docs, you need python 2.7.9 or higher.

edit: I didn't see your version (2.7.5). So yes, it is a version issue. Updating python would solve it.

SSL InsecurePlatform error when using Requests package

Use the somewhat hidden security feature:

pip install requests[security]
or
pip install pyOpenSSL ndg-httpsclient pyasn1

Both commands install following extra packages:

  • pyOpenSSL
  • cryptography
  • idna

Please note that this is not required for python-2.7.9+.

If pip install fails with errors, check whether you have required development packages for libffi, libssl and python installed in your system using distribution's package manager:

  • Debian/Ubuntu - python-dev libffi-dev libssl-dev packages.

  • Fedora - openssl-devel python-devel libffi-devel packages.

Distro list above is incomplete.

Workaround (see the original answer by @TomDotTom):

In case you cannot install some of the required development packages, there's also an option to disable that warning:

import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()

If your pip itself is affected by InsecurePlatformWarning and cannot install anything from PyPI, it can be fixed with this step-by-step guide to deploy extra python packages manually.

pip install' error: InsecurePlatformWarning

Thanks to I'L'I in chat -- I had to change my permissions here sudo chown -R Ryan "/Users/Ryan/Library/Caches/pip/http'' then reinstall get-pip.py.



Related Topics



Leave a reply



Submit