相关疑难解决方法(0)

抑制InsecureRequestWarning:在Python2.6中进行未验证的HTTPS请求

我正在使用pyVmomi在Python2.6中编写脚本,并使用其中一种连接方法:

service_instance = connect.SmartConnect(host=args.ip,
                                        user=args.user,
                                        pwd=args.password)
Run Code Online (Sandbox Code Playgroud)

我收到以下警告:

/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py:734: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)
Run Code Online (Sandbox Code Playgroud)

有趣的是,我没有使用pip安装urllib3(但它位于/usr/lib/python2.6/site-packages/requests/packages/urllib3/).

我按照这里的建议尝试过

import urllib3
...
urllib3.disable_warnings()
Run Code Online (Sandbox Code Playgroud)

但这并没有改变任何事情.

python python-2.6 suppress-warnings urllib3 pyvmomi

283
推荐指数
11
解决办法
31万
查看次数

标签 统计

python ×1

python-2.6 ×1

pyvmomi ×1

suppress-warnings ×1

urllib3 ×1