背景
脚本中使用了paramiko,在高版本的3.9Python环境下很丝滑。
给到指定环境因为Python版本不同(3.6),有Warning信息很碍事。
报警信息
/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.
from cryptography.hazmat.backends import default_backend
解决
import warnings
在导入前
import warnings
warnings.filterwarnings( action = 'ignore' , module = '.*paramiko.*' )
import paramiko
在导入后(试了没用)
import warnings
from cryptography.utils import CryptographyDeprecationWarning
warnings.filterwarnings( "ignore" , category = CryptographyDeprecationWarning )