python2.7 提示InsecureRequestWarning警告问题
日志信息:
/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py:857: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
关掉该日志提示的方法:
1. 全局搜索在哪里引用了warnings,比如我是在 odoo/openerp/http.py 这个路径下的文件里引用到了warnings包:
然后在这个引入下面加上 warnings.filterwarnings("ignore"),参数ignore为忽略警告的意思
代码片段:
import warnings
warnings.filterwarnings("ignore")
备注:日志链接里提供的解决办法(本人亲测无效)
在InsecureRequestWarning的警告里也提供了一个链接:https://urllib3.readthedocs.io/en/latest/advanced-usage.html,这个链接里也给出了一些禁止输出这个警告的办法:
就是在引入了urllib3的文件里添加 urllib3.disable_warnings(),本人亲测无效,不知道其他人有没有效果,需要的可以自行测试下
代码如下:
import urllib3
urllib3.disable_warnings()
补充:warnings.filterwarnings("ignore")里可设置的参数: