环境:
win7_64x
python3.5
脚本使用了paramiko模块。用PYINSTALLER生成EXE的时候报错:
Unknown exception: Multibackend cannot be initialized with no backends. If you are seeing this error when trying to use default_backend() please try uninstalling and reinstalling cryptography.
网友写了一个补丁。加入脚本就能解决:
def patch_crypto_be_discovery():
"""
Monkey patches cryptography's backend detection.
Objective: support pyinstaller freezing.
"""
from cryptography.hazmat import backends
try:
from cryptography.hazmat.backends.commoncrypto.backend import backend as be_cc
except ImportError:
be_cc = None
try:
from cryptography.hazmat.backends.openssl.backend import backend as be_ossl
except ImportError:
be_ossl = None
backends._available_backends_list = [
be for be in (be_cc, be_ossl) if be is not None
]
然后在脚本开头调用就可以了~
patch_crypto_be_discovery()
貌似是依赖的cryptography模块的问题。没怎么看懂。反正解决了~ PS:网上不少安装paramiko的。好象都是去哪里下载。我是直接PIP INSTALL直接搞定的。没什么问题,包括pyinstaller:
pip install paramiko
pip install pyinstaller