CryptographyDeprecationWarning:Python 核心团队不再支持 Python 3.6

Kan*_*ngh 10 python python-3.x python-cryptography

我将系统从 python 2 升级到 python 3,现在当我运行代码时:

from cryptography.hazmat.backends import default_backend
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

/usr/local/lib/python3.6/site-packages/paramiko/transport.py:33:
CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python 
core team. Therefore, support for it is deprecated in cryptography and will be 
removed in a future release.
Run Code Online (Sandbox Code Playgroud)

如何解决呢?

小智 7

在Ubuntu上

sudo apt-get upgrade docker-compose
Run Code Online (Sandbox Code Playgroud)

docker-compose 必须是 2.X,之后您需要将旧命令引用到新命令,因此请执行此操作

alias docker-compose='docker compose'
Run Code Online (Sandbox Code Playgroud)

  • 技巧(根据这个答案)是使用“docker compose [up/down/logs/status]”而不是“docker-compose [up/down/logs/status]”。删除连字符。 (4认同)

Luv*_*hon 5

我今天遇到了这个问题并进行了一些挖掘。由于os未提供,我认为您可以考虑以下选项之一:

  1. 升级你的Python版本。这可能是自 python 3.6 终止以来的最佳选择。

  2. 您可能在代码中使用 SSH。考虑安装旧版本的paramiko

  3. 您可以在导入 Paramiko 之前使用以下代码行抑制警告:

    import warnings 
    warnings.filterwarnings(action='ignore',module='.*paramiko.*')
    
    Run Code Online (Sandbox Code Playgroud)

或者如果您想更有选择性地抑制特定的弃用警告:

import warnings
from cryptography.utils import CryptographyDeprecationWarning
warnings.filterwarnings("ignore", category=CryptographyDeprecationWarning)
Run Code Online (Sandbox Code Playgroud)

选项 3 的来源

  1. 当需要使用 conda 时检查是否使用 pip 安装了它。