Collection of troubleshooting methods for Python requests, pythonrequests

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.