解决 CryptographyDeprecationWarning: Python 3.8 is no longer supported by the Python core team 问题
问题背景:
在使用 Python 3.8 环境开发时,可能会遇到如下警告信息:
CryptographyDeprecationWarning: Python 3.8 is no longer supported by the Python core team and support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.8. from cryptography.fernet import Fernet报错原因分析
该警告明确指出,cryptography 库的最新版本(如 47.0.0)已不再支持 Python 3.8。随着 Python 3.8 官方停止支持,主流库也在逐步淘汰对其的兼容。因此,安装最新版 cryptography 会导致此兼容性问题。
解决方案
解决思路是降级安装一个仍支持 Python 3.8 的旧版本。为了提高下载速度,我们使用清华大学 TUNA 协会维护的 PyPI 镜像源。
操作步骤:
1.卸载当前版本
首先卸载导致冲突的最新版本库
pip uninstall cryptography2.安装兼容版本
安装经过验证的兼容版本42.0.0。使用-i参数指定清华源,以获得更快的下载速度。
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple cryptography==42.0.0