【问题标题】:CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core teamCryptographyDeprecationWarning:Python 核心团队不再支持 Python 2
【发布时间】:2023-04-04 14:28:01
【问题描述】:

我收到此错误:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/crypto.py:14: CryptographyDeprecationWarning:Python 2 不再受支持 Python核心团队。现在在密码学中已弃用对它的支持, 并将在下一个版本中删除。从密码学导入 实用程序,x509

我已尝试更新密码学模块和 python。这个问题的解决方法是什么?

【问题讨论】:

  • 升级到 Python 3.x。
  • Python 2 自 2010 年以来没有收到过重大更新,它的最后一个补丁是在 2019 年。它在 2020 年初日落,不再收到安全更新,因此使用加密模块可能不是最好的主意。如果我是你,我会尽快升级到 Python 3。
  • 如果您使用的是 Python 3,或者您不知道它们之间的区别,请尝试使用 python3 命令运行您的代码,而不仅仅是 python。您的系统可能有与python2 相关联的python,而不是python3
  • 警告!= 错误。

标签: python python-2.7 cryptography


【解决方案1】:

macOS Monterey 将/usr/bin/python 作为 Python 2.7.18 以及一组默认软件包提供。这个 Python 是作为与旧软件兼容的最终后备提供的。执行这个 Apple 提供的 Python 时,您将看到以下初始消息:

WARNING: Python 2.7 is not recommended. 
This version is included in macOS for compatibility with legacy software. 
Future versions of macOS will not include Python 2.7. 
Instead, it is recommended that you transition to using 'python3' from within Terminal.

由于他们发布了一组多年来一直发布的软件包,其中包括 cryptography,它还弃用了 Python 2 支持,并开始发出关于在 3.3 版中放弃支持的警告。 Apple 发布了 3.3.2 版本,这是支持 Python 2 的 cryptography 的最终版本。

唯一真正的解决办法是停止使用 Python 2。您可以从 python.org 安装更新的 Python,使用 pyenv 或 conda 等工具,或者使用 Apple 的 Python 3,但需要迁移。当然,Apple 很可能会在明年 macOS 13 发布时放弃他们的 py2 安装。

【讨论】:

猜你喜欢
  • 2022-08-18
  • 1970-01-01
  • 1970-01-01
  • 2023-03-04
  • 1970-01-01
  • 2010-09-17
  • 2017-11-24
  • 1970-01-01
  • 2019-05-20
相关资源
最近更新 更多