Python paramiko / error:CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release. from cryptography.hazmat.backends import default_backend
如上的错误发生在Python2的环境中使用Paramiko的时候,提示了如上的错误:
具体如下:
1 2 3 4 5 6 7 8 9 10 11 |
D:\PyCharm_data\BatchRun\venv\Scripts\python.exe D:/PyCharm_data/BatchRun/run.py D:\PyCharm_data\BatchRun\venv\lib\site-packages\paramiko\transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release. from cryptography.hazmat.backends import default_backend ----------- config_host_1 {u'os_passwd': u'oracle', u'os_user': u'alice', u'ip_addr': u'192.168.27.128', u'install_media': u'', u'database': u'mysql'} ----------- config_host_2 {u'os_passwd': u'oracle', u'os_user': u'bobby', u'ip_addr': u'192.168.27.121', u'database': u'mongodb'} Process finished with exit code 0 |
解决这个问题的方法是:
将cryptography的版本降为2.4.2
具体如下:



然后,再次执行前面的脚本就没问题了:
1 2 3 4 5 6 7 8 9 |
D:\PyCharm_data\BatchRun\venv\Scripts\python.exe D:/PyCharm_data/BatchRun/run.py ----------- config_host_1 {u'os_passwd': u'oracle', u'os_user': u'alice', u'ip_addr': u'192.168.27.128', u'install_media': u'', u'database': u'mysql'} ----------- config_host_2 {u'os_passwd': u'oracle', u'os_user': u'bobby', u'ip_addr': u'192.168.27.121', u'database': u'mongodb'} Process finished with exit code 0 |