Welcome to thatlinuxbox.com Saturday, December 21 2024 @ 11:47 AM UTC
Python requests urllib3 SSL warning
- Tuesday, June 06 2017 @ 05:36 PM UTC
- Contributed by: Dan Stoner
- Views: 6,189
My Linux development computers are still running Ubuntu 14.04 which includes Python 2.7.
One of the libraries I commonly use to access websites or APIs from Python is "Requests: HTTP for Humans". Requests in turn leverages urllib3. The following warning began popping up a while ago when making requests to SSL sites:
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 https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
The solution is actually quite simple (especially if one is developing in a virtual environment), using pip install with the extra bits including the brackets:
$ pip install urllib3[secure]
From:
https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2
If you aren't developing in a python virtual environment... start developing in a pyton virtual environment! I suggest virtualenvwrapper over vanilla virtualenv.
https://virtualenvwrapper.readthedocs.io/en/latest/
The following comments are owned by whomever posted them. This site is not responsible for what they say.