Suppress InsecureRequestWarning: Unverified HTTPS request is being made in Python2.6
You can disable any Python warnings via the
PYTHONWARNINGS environment variable. In this case, you want:
export PYTHONWARNINGS="ignore:Unverified HTTPS request"
To disable using Python code (
requests >= 2.16.0):
requests < 2.16.0, see original answer below.
The reason doing
urllib3.disable_warnings() didn't work for you is because it looks like you're using a separate instance of urllib3 vendored inside of requests.
I gather this based on the path here:
To disable warnings in requests' vendored urllib3, you'll need to import that specific instance of the module:
import requestsfrom requests.packages.urllib3.exceptions import InsecureRequestWarningrequests.packages.urllib3.disable_warnings(InsecureRequestWarning)
This is the answer in 2017.
urllib3 not a part of
Per this github comment, one can disable
urllib3 request warnings via
requests in a 1-liner:
This will suppress all warnings though, not just
InsecureRequest (ie it will also suppress
InsecurePlatform etc). In cases where we just want stuff to work, I find the conciseness handy.