简体   繁体   中英

Error in opening Python executable file, created using cx_freeze

Before asking this question have checked other queries ( cx_freeze ImportError when executing file ) was related to my issue, error was "DLL load failed" but my case is "No module named".
My question is - I have created a Python executables using cx_freeze but when I open the Main.exe file, the application opens with Traceback errors on it..

    import sys
    from cx_Freeze import setup, Executable

    # Dependencies are automatically detected, but it might need fine tuning.
    build_exe_options = {
        "optimize": 2,
        "includes": [],
        "compressed": True,
        "copy_dependent_files": True,
        "create_shared_zip": False,
        "append_script_to_exe": True,
        "include_in_shared_zip": False,

        "include_files":[('vPlot.ui'),
                         ('vPlot.py'),
                         ('company.jpg')], 
        "include_msvcr": True,
        "packages": [],
    }

    # GUI applications require a different base on Windows (the default is for a
    # console application).
    base = None
    if sys.platform == "win32":
       base = "Win32GUI"

    setup(  name = "plcTest",
            description = "plcTest!",
            options = {"build_exe": build_exe_options},
            executables = [Executable("Main.py",
                                      base=base,
                                      copyDependentFiles=True,
                                      appendScriptToExe=True)])

my error is ( http://i.imgur.com/TSVg6Ft.png ), I can't find the file "'matplotlib.backends.backend_tkagg'", please give your advise, thanks in advance

cx-freeze have good module analysis but sometimes it is fails. Especially back and modules.

Matplotlib uses tkagg (i am not sure it is package name)as backend gui module. To solve this, you have two options;

1- import missing package somewhere in your code

2- pass package name to cx-freeze as parameter.

Example: i used cx-freeze from command-line

cxfreeze FooMain.py --include-module=simplejson, lxml  # FooMain.py my main script

edit: using python build_exe_options

"packages": ["simplejson", "lxml"],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM