簡體   English   中英

打開使用cx_freeze創建的Python可執行文件時出錯

[英]Error in opening Python executable file, created using cx_freeze

在問這個問題之前,已經檢查了其他查詢( 執行文件時為cx_freeze ImportError )與我的問題有關,錯誤為“ DLL加載失敗”,但我的情況為“未命名模塊”。
我的問題是-我已經使用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)])

我的錯誤是( http://i.imgur.com/TSVg6Ft.png ),我找不到文件“'matplotlib.backends.backend_tkagg'”,請提供建議,謝謝。

cx-freeze具有很好的模塊分析能力,但有時會失敗。 特別是背面和模塊。

Matplotlib使用tkagg (我不確定它是軟件包名稱)作為后端gui模塊。 要解決此問題,您有兩個選擇;

1-在您的代碼中的某處導入丟失的軟件包

2-將軟件包名稱傳遞給cx-freeze作為參數。

示例:我從命令行使用了cx-freeze

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

編輯:使用python build_exe_options

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM