SoFunction
Updated on 2024-11-20

A collection of ways to solve Python requests errors.

Both the python version and the ssl version can cause requests to throw some errors when requesting https sites, so it's best to use a newer version.

1 Python2.6x use requests

An old Centos machine running an ancient application reports an error after adding a new module InsecurePlatformWarning: A true SSLContext object is not available.

/usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py:132: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see /en/latest/#ssl-warnings
  InsecurePlatformWarning

method settle an issue

Using an older version of requests

$pip install requests==2.5.3

Or install it like this

$ pip install requests[security]

2 SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

The error is as follows Version python2.7.5

Traceback (most recent call last):
  File "./", line 24, in <module>
  response = (url1, headers=headers)
  File "build/-x86_64/egg/requests/", line 52, in get
  File "build/-x86_64/egg/requests/", line 40, in request
  File "build/-x86_64/egg/requests/", line 209, in request
  File "build/-x86_64/egg/requests/", line 624, in send
  File "build/-x86_64/egg/requests/", line 300, in _build_response
  File "build/-x86_64/egg/requests/", line 611, in send
: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

cure

You can disable verify

>>> ('', verify=True)
Question address python-requests-throwing-up-sslerror

3 SSLError: bad handshake

SSLError: bad handshake: Error([(‘SSL routines', ‘SSL3_GET_SERVER_CERTIFICATE', ‘certificate verify failed')],) python2.7.5
pip uninstall -y certifi && pip install certifi==2015.04.28

For discussion see:/rackspace/pyrax/issues/601

The above is a small introduction to the Python requests error reporting method set, I hope to help you, if you have any questions welcome to leave me a message, I will reply to you in a timely manner!