没有模块_cffi_用cx_freeze冻结

时间:2019-05-09 09:20:42

标签: python paramiko cx-freeze

因此,我正在开发一个PySide应用程序(适用于Python的Qt),我想使用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])

enter image description here

我认为这与我在应用程序中使用的 Paramiko 软件包有关。有没有人遇到并解决过这个问题?

1 个答案:

答案 0 :(得分:0)

我认为我是通过如下修改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

本质上:

  1. cffi中明确指定cryptographybuild_exe_options的导入
  2. 复制libcrypto-1_1-x64.dl l和libssl-1_1-x64.dll dlls
  3. 将后端明确指定为openssl_backend而不是default_backend