【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
安装完之后,保存
待续

赠人玫瑰
手留余香
我们曾如此渴望命运的波澜,到最后才发现:人生最曼妙的风景,竟是内心的淡定与从容……我们曾如此期盼外界的认可,到最后才知道:世界是自己的,与他人毫无关系!-杨绛先生
如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .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格式转换等