问题背景在使用 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 cryptography42.0.0