python - 没有使用 cx_Freeze 冻结模块 _cffi_
问题描述
我正在开发一个 PySide 应用程序(Qt for Python),我想使用 cx_Freeze 冻结它。
当我python setup.py build
使用下面的设置文件运行时,它会创建没有错误的构建目录,但是当我运行生成的 .exe 文件时,我收到如下所示的错误消息:
from cx_Freeze import setup, Executable
target = Executable(
script="main_window.py",
base = "Win32GUI",
icon="images\\icon.ico"
)
setup(name = "DemiurgoXMLgen" ,
version = "0.1" ,
description = "" ,
options={'build_exe': {'include_files': ['images\\']}},
executables = [target])
我认为这与我在应用程序中使用的Paramiko包有关。有没有人遇到并解决了这个问题?
解决方案
我想我通过setup.py
如下修改解决了它:
import os.path
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
build_exe_options = {"include_files" : [
os.path.join(PYTHON_INSTALL_DIR, "DLLs", "libcrypto-1_1-x64.dll"),
os.path.join(PYTHON_INSTALL_DIR, "DLLs", "libssl-1_1-x64.dll")]}
build_exe_options = {"packages": ['cffi', 'cryptography'], 'include_files': ['images\\', os.path.join(PYTHON_INSTALL_DIR, "DLLs", "libcrypto-1_1-x64.dll"),
os.path.join(PYTHON_INSTALL_DIR, "DLLs", "libssl-1_1-x64.dll")]}
target = Executable(
script="main_window.py",
base = "Win32GUI",
icon="images\\icon.ico"
)
setup(name = "DemiurgoXMLgen" ,
version = "0.1" ,
description = "" ,
options={'build_exe': build_exe_options},
executables = [target])
并在paramiko->ed25519key.py
导入中修改:
从 cryptography.hazmat.backends 导入 default_backend
from cryptography.hazmat.backends import openssl as openssl_backend
本质上:
- 明确指定
cffi
andcryptography
in的导入build_exe_options
- 复制l的dll和
libcrypto-1_1-x64.dl
libssl-1_1-x64.dll
- 明确指定后端作为
openssl_backend
而不是default_backend
推荐阅读
- c# - 将日期格式 01/05/2018 和 01/ma/2018 转换为 (dd/mm/yyyy) 格式,并使用 c# 将相同的格式保存到 excel 中
- php - php MVC 和 GD 库
- php - htaccess 多域与 Wordpress
- angular - * div 类中的 Ngfor 不起作用 - Angular 6 和 Bootstrap
- c# - 我的 AAD 身份验证回复网址有什么问题?
- php - 将 pdf 文件转换为 html 的示例 php 代码
- c++ - 为什么 STL 算法不会为 std::tuple 重载?
- java - 考虑到字符串具有要忽略的字符,Java 中是否有一个函数允许您将字符串转换为 Int?
- javascript - 如何在 Kentico 中删除 javascript 类型属性
- hyperledger-composer - 错误:Ubuntu 18.04 中不支持 Ubuntu 仿生超级账本作曲家