cx_Freeze converted GUI-app (tkinter) crashes after pressing plot button

前端 未结 4 758
一向
一向 2020-11-28 14:03

I\'ve been dealing with this for days now and hope to find some help. I developed a GUI-application with imported modules tkinter, numpy, scipy, matplotlib, which runs fine

4条回答
  •  难免孤独
    2020-11-28 14:39

    I have followed @J.J. Hakala's answer, but I found that it's not necessary copy all mkl_*.dll and libiomp5md.dll files. For me it worked with libiomp5md.dll mkl_core.dll mkl_def.dll mkl_intel_thread.dll. This helps to reduce the final bundle size in ~500MB.

    Also, you can include the files you want to copy in the include_files option. You also could only want to include them if sys.platform is win32.

    I'm using Anaconda as well as @Matt Williams, so, changing a bit the OP's code:

    import cx_Freeze
    import matplotlib
    import sys
    import numpy
    import tkinter
    import os
    
    PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
    
    build_exe_options = {"includes":   ["matplotlib.backends.backend_tkagg","matplotlib.pyplot",
                                 "tkinter.filedialog","numpy"],
                         "include_files":[(matplotlib.get_data_path(), "mpl-data")],
                         "excludes":[],
                        }
    
    base = None
    
    if sys.platform == "win32":
        base = "Win32GUI"
        DLLS_FOLDER = os.path.join(PYTHON_INSTALL_DIR, 'Library', 'bin')
    
        dependencies = ['libiomp5md.dll', 'mkl_core.dll', 'mkl_def.dll', 'mkl_intel_thread.dll']
    
        for dependency in dependencies:
            build_exe_options['include_files'].append(os.path.join(DLLS_FOLDER, dependency))
    
    executables = [cx_Freeze.Executable("test.py", base=base)]
    
    cx_Freeze.setup(
        name = "test it",
        options = {"build_exe": build_exe_options},
        version = "1.0",
        description = "I test it",
        executables = executables)
    

提交回复
热议问题