最新消息:走过的,离开的,已经错过,新开始2016

解决python CryptographyDeprecationWarning提示版本低不再支持问题

技术随笔 果果 549浏览 0评论


古董python2.7,最近又写了几个程序,需要用到pymysql 连接MySQL数据库,但是一直出现一个警告提示,看着烦。

/usr/lib/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py:395: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.

意思是将在未来版本不支持Python 2,但是我这生产环境,又不能升级。

网上说安装低版本的cryptography,比如
pip install cryptography==2.6 但是我这里好像没找到2.6的版本。

看到另一个直接修改代码,把警告去掉。

修改 /usr/lib64/python2.7/site-packages/cryptography/__init__.py
在最后面把版本判断注释掉

#if sys.version_info[0] == 2:
#    warnings.warn(
#        "Python 2 is no longer supported by the Python core team. Support for "
#        "it is now deprecated in cryptography, and will be removed in the "
#        "next release.",
#        CryptographyDeprecationWarning,
#        stacklevel=2,
#    )

Windows 路径 C:\python2.7\Lib\site-packages\cryptography\__init__.py

根据自己安装的路径修改。

转载请注明:果果.IT » 解决python CryptographyDeprecationWarning提示版本低不再支持问题

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址