报错原因: python 3.6 和 Cryptography 39.0.1 版本不兼容
解决办法: A.降低Cryptography至3.4.8,就可以正常运行;
B.升级python 至3.9 ,高版本的python可以兼容这些冲突
下面是方法A的执行过程:
执行python3 test.py 发现报错提示
# python3 test.py
/usr/local/lib/python3.6/site-packages/paramiko/transport.py:32: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography (40.0) will be the last to support Python 3.6.
from cryptography.hazmat.backends import default_backend
0.00
检查已安装的Cryptography版本信息
# pip3 show cryptography
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Name: cryptography
Version: 39.0.1
Summary: cryptography is a package which provides cryptographic recipes and primitives to Python developers.
Home-page: https://github.com/pyca/cryptography
Author: The Python Cryptographic Authority and individual contributors
Author-email: cryptography-dev@python.org
License: (Apache-2.0 OR BSD-3-Clause) AND PSF-2.0
Location: /usr/local/lib64/python3.6/site-packages
Requires: cffi
Required-by: paramiko, pyOpenSSL
卸载已安装的cryptography
# pip uninstall -y cryptography
Found existing installation: cryptography 39.0.1
Uninstalling cryptography-39.0.1:
Would remove:
/usr/local/lib64/python3.6/site-packages/cryptography-39.0.1.dist-info/*
/usr/local/lib64/python3.6/site-packages/cryptography/*
Successfully uninstalled cryptography-39.0.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
重新安装低版本cryptography(3.4.8)
# pip3 install cryptography==3.4.8
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Collecting cryptography==3.4.8
Downloading cryptography-3.4.8-cp36-abi3-manylinux_2_24_x86_64.whl (3.0 MB)
|████████████████████████████████| 3.0 MB 395 kB/s
Requirement already satisfied: cffi>=1.12 in /usr/local/lib64/python3.6/site-packages (from cryptography==3.4.8) (1.15.1)
Requirement already satisfied: pycparser in /usr/lib/python3.6/site-packages (from cffi>=1.12->cryptography==3.4.8) (2.14)
Installing collected packages: cryptography
Successfully installed cryptography-3.4.8
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
再次执行python3 test.py恢复正常
# python3 test.py
0.00