【Python】Unresolved reference 'InsecureRequestWarning' Inspection info: This inspecti

在Pycharm中导入包的时候,会存在报错问题:

Unresolved reference 'InsecureRequestWarning' less... (Ctrl+F1) 

Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items

 

如下

from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 禁用安全请求警告 requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

解决InsecureRequestWarning警告

 

不要使用verify=False

或者requests.packages.urllib3.disable_warnings()

不要忽视警告

 

尝试过这几种:

在语句前增加

requests.packages.urllib3.disable_warnings()

 

# 导入包时导入

import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

 

# python3
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# python2
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

 

正确的做法

参考 

https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl

 

Certificate verification
It is highly recommended to always use SSL certificate verification.By default, urllib3 does not verify HTTPS requests.

In order to enable verification you will need a set of root certificates. The easiestand most reliable method is to use thecertifi package which provides Mozilla’s root certificate bundle:

pip install certifi

 

安装几个包 

pip install cryptography 
pip install pyOpenSSL 
pip install certifi

 

我这机器同时安装了Python2 和 Python3 ,可以采取一下方式安装:

 

D:\CODE\WORK_TEST\YHCode\PreEnv>py -2 "C:\Python27\Scripts\pip.exe"  install certifi

D:\CODE\WORK_TEST\YHCode\PreEnv>py -2 "C:\Python27\Scripts\pip.exe"  install cryptography

D:\CODE\WORK_TEST\YHCode\PreEnv>py -2 "C:\Python27\Scripts\pip.exe" install pyOpenSSL

安装完之后,保存

 

待续

posted @   念槐聚  阅读(949)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
历史上的今天:
2015-07-02 创业相关
2015-07-02 关于HTML5与移动开发
2014-07-02 番茄工作法
2014-07-02 【CI】系列三.宿主机KVM配置及vdi与vmdk格式转换等
点击右上角即可分享
微信分享提示