没有模块_cffi_用cx_Freeze冻结 [英] No module _cffi_ freezing with cx_Freeze

查看:57
本文介绍了没有模块_cffi_用cx_Freeze冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发PySide应用程序(适用于Python的Qt),我想使用cx_Freeze将其冻结。

I am developing a PySide application (Qt for Python) and I would like to freeze it using cx_Freeze.

当我运行 python setup时.py build 使用下面的安装文件,它创建的构建目录没有错误,但是当我运行生成的.exe文件时,出现以下错误消息:

When I run python setup.py build using my setup file below, it creates the build directory without errors, but then when I run the .exe file generated, I get the error message shown below:

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 包。有没有人遇到并解决了这个问题?

I think it has something to do with the Paramiko package I am using in my application. Has anyone encountered and solved this problem?

推荐答案

我想我是通过修改 setup.py 如下:

I think I solved it by modifying setup.py as below:

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 导入:

from cryptography.hazmat.backends import default_backend

from cryptography.hazmat.backends import openssl as openssl_backend

本质上:


  1. 明确指定 cffi 和 build_exe_options

  2. 中的加密复制 dlls 用于 libcrypto-1_1-x64.dl l和 libssl-1_1-x64.dll

  3. 将后端明确指定为 openssl_backend 而不是 default_backend

  1. explicitly specify the import of cffi and cryptography in build_exe_options
  2. copy the dlls for libcrypto-1_1-x64.dll and libssl-1_1-x64.dll
  3. explicitly specify the backend as openssl_backend instead of default_backend

这篇关于没有模块_cffi_用cx_Freeze冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆