简体   繁体   English

打开使用cx_freeze创建的Python可执行文件时出错

[英]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". 在问这个问题之前,已经检查了其他查询( 执行文件时为cx_freeze ImportError )与我的问题有关,错误为“ DLL加载失败”,但我的情况为“未命名模块”。
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.. 我的问题是-我已经使用cx_freeze创建了Python可执行文件,但是当我打开Main.exe文件时,应用程序将打开并带有Traceback错误。

    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 我的错误是( http://i.imgur.com/TSVg6Ft.png ),我找不到文件“'matplotlib.backends.backend_tkagg'”,请提供建议,谢谢。

cx-freeze have good module analysis but sometimes it is fails. cx-freeze具有很好的模块分析能力,但有时会失败。 Especially back and modules. 特别是背面和模块。

Matplotlib uses tkagg (i am not sure it is package name)as backend gui module. Matplotlib使用tkagg (我不确定它是软件包名称)作为后端gui模块。 To solve this, you have two options; 要解决此问题,您有两个选择;

1- import missing package somewhere in your code 1-在您的代码中的某处导入丢失的软件包

2- pass package name to cx-freeze as parameter. 2-将软件包名称传递给cx-freeze作为参数。

Example: i used cx-freeze from command-line 示例:我从命令行使用了cx-freeze

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

edit: using python build_exe_options 编辑:使用python build_exe_options

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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