0

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

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])

enter image description here

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

jpeg
  • 2,372
  • 4
  • 18
  • 31
Francesco Pegoraro
  • 778
  • 13
  • 33
  • Please post the error message as text, not as an image, see [Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/q/285551/8516269) – jpeg Jun 25 '19 at 13:30
  • Yeah I know, I posted it like this because windows wouldn't let me copy it as text :( – Francesco Pegoraro Jun 25 '19 at 13:58
  • Yeah I know, then you need to type, which is annoying... or use e.g. [Console2](https://sourceforge.net/projects/console/), which allows you to select and copy text :) – jpeg Jun 25 '19 at 14:05

1 Answers1

0

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])

and modifying in paramiko->ed25519key.py the import:

from cryptography.hazmat.backends import default_backend

from cryptography.hazmat.backends import openssl as openssl_backend

Essentially:

  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
Francesco Pegoraro
  • 778
  • 13
  • 33