项目场景:
使用pyinstaller 打包exe
python版本 3.10.7
pyinstaller 版本 5.12.0
问题描述
打包过程中产生如下问题
15584 INFO: Loading module hook 'hook-cryptography.py' from 'C:\\Users\\Administrator\\Documents\\git-fork\\python-project\\venv\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
17069 WARNING: hook-cryptography: failed to determine whether cryptography is using OpenSSL >= 3.0.0
Traceback (most recent call last):
File "C:\Users\Administrator\Documents\git-fork\python-project\venv\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-cryptography.py", line 62, in <module>
uses_openssl3 = _check_cryptography_openssl3()
File "C:\Users\Administrator\Documents\git-fork\python-project\venv\lib\site-packages\PyInstaller\isolated\_parent.py", line 420, in wrapped
return call(function, *args, **kwargs)
File "C:\Users\Administrator\Documents\git-fork\python-project\venv\lib\site-packages\PyInstaller\isolated\_parent.py", line 389, in call
return isolated.call(function, *args, **kwargs)
File "C:\Users\Administrator\Documents\git-fork\python-project\venv\lib\site-packages\PyInstaller\isolated\_parent.py", line 319, in call
raise RuntimeError(f"Child process call to {function.__name__}() failed with:\n" + output)
RuntimeError: Child process call to _check_cryptography_openssl3() failed with:
File "C:\Users\Administrator\Documents\git-fork\python-project\venv\lib\site-packages\PyInstaller\isolated\_child.py", line 63, in run_next_command
output = function(*args, **kwargs)
File "C:\Users\Administrator\Documents\git-fork\python-project\venv\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-cryptography.py", line 60, in _check_cryptography_openssl3
return bool(backend._lib.CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)
AttributeError: module 'lib' has no attribute 'CRYPTOGRAPHY_OPENSSL_300_OR_GREATER'
原因分析:
具体问题是当前版本的cryptography有问题确实openssl库支持
解决方案:
参考链接
更换对应版本库就可以解决
pip install cryptography==38.0.4 解决问题