view raw
Luke Peckham Luke Peckham - 1 year ago 67
Python Question

SSL InsecurePlatform error when using Requests package

Im using Python 2.7.3 and Requests. I installed Requests via pip. I believe it's the latest version. I'm running on Debian Wheezy.

I've used Requests lots of times in the past and never faced this issue, but it seems that when making https requests with

I get an

The error mentions
, but I don't have that installed. I did install it to check if it resolved the error, but it didn't.

/util/ InsecurePlatformWarning: A true SSLContext object is not
available. This prevents urllib3 from configuring SSL appropriately and
may cause certain SSL connections to fail. For more information, see

Any ideas as to why I'm getting this? I've checked the docs, as specified in the error message, but the docs are saying to import urllib3 and either disable the warning, or provide a certificate.


Use the somewhat hidden security feature:

pip install 'requests[security]'

This installs following extra packages:

  • pyOpenSSL
  • ndg-httpsclient
  • pyasn1

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

If pip install fails with errors, check whether you have following additional development packages (libffi, libssl and python) installed in your system (most preferrably via 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