It’s not so common to be concerned about HTTPS endpoints in the development stage. Thus, it feels like suppressing warning messages is a common thing, right. So, as I was playing around with a dockerized Python app I was getting:
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. warning again and again. Here are few things you could try to disable this specific warning.
- Python 3
- Python packages: urllib3, requests
Python 3 code update
Insert the following code:
from requests.packages import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
If you want to disable all warnings, add this instead:
from requests.packages import urllib3 urllib3.disable_warnings()
Set an env variable in Linux / MacOS:
export PYTHONWARNINGS="ignore:Unverified HTTPS request"
$env:PYTHONWARNINGS="ignore:Unverified HTTPS request"
Strongly recommended not to apply it in a production environment. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.