Collection of troubleshooting methods for Python requests, pythonrequests
Both the python version and the ssl version will cause some errors when requests the https website. It is best to use the new version.
1 Python2.6x use requests
An old Centos machine runs an old application. When A new module is added, an error is returned, 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 signing 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 https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
Solution
Use the old version of requests
$pip install requests==2.5.3
Or install
$ pip install requests[security]
2 SSL3_GET_SERVER_CERTIFICATE: certificate verify failed
The error is as follows: python2.7.5
Traceback (most recent call last ):
File "./test. py", line 24, in <module>
Response = requests. get (url1, headers = headers)
File "build/bdist. linux-x86_64/egg/requests/api. py", line 52, in get
File "build/bdist. linux-x86_64/egg/requests/api. py", line 40, in request
File "build/bdist. linux-x86_64/egg/requests/sessions. py", line 209, in request
File "build/bdist. linux-x86_64/egg/requests/models. py", line 624, in send
File "build/bdist. linux-x86_64/egg/requests/models. py", line 300, in _ build_response
File "build/bdist. linux-x86_64/egg/requests/models. py", line 611, in send
Requests. exceptions. SSLError: [Errno 1] _ ssl. c: 503: error: 14090086: SSL routines: SSL3_GET_SERVER_CERTIFICATE: certificate verify failed
Solution
Disable verify
>>> Requests. get ('https: // google.com ', verify = True)
Problem 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
See: https://github.com/rackspace/pyrax/issues/601
The above is a collection of Python requests error reporting methods introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in time!