cx_freeze和python 3.2.2的问题?

时间:2012-01-31 00:50:38

标签: python pyqt4 cx-freeze

我正在尝试使用cx_freeze 4.2.3冻结python 3.2.2脚本。源脚本使用PyQt4,我不确定这是否是该问题的潜在来源。 Python在构建过程中崩溃。这是命令行输出:

  
    

C:\ Python32 \ New Folder> python setup.py build

         

运行构建

         

运行build_exe

         

复制C:\ Python32 \ Lib \ site-packages \ cx_Freeze \ bases \ Win32GUI.exe - >建立\ exe.win32-3.2 \ APP.EXE

         

复制C:\ WINDOWS \ system32 \ python32.dll - >建立\ exe.win32-3.2 \ python32.dll

  

此时Python本身在Windows中崩溃,并提供“发送错误报告”MS对话框:

  

python.exe遇到问题需要关闭。对不起   给您带来不便。

这是我的setup.py文件:

from cx_Freeze import setup, Executable

GUI2Exe_Target_1 = Executable(
    script = "script.pyw",
    initScript = None,
    base = 'Win32GUI',
    targetName = "app.exe",
    compress = True,
    copyDependentFiles = True,
    appendScriptToExe = False,
    appendScriptToLibrary = False,
    icon = "icon.png"
    ) 
excludes = ["pywin", "tcl", "pywin.debugger", "pywin.debugger.dbgcon",
        "pywin.dialogs", "pywin.dialogs.list", "win32com.server",
        "email"] 
includes = ["PyQt4.QtCore","PyQt4.QtGui","win32gui","win32com","win32api","html.parser","sys","threading","datetime","time","urllib.request","re","queue","os"] 
packages = [] 
path = [] 
setup(
    version = "1.0",
    description = "myapp",
    author = "me",
    author_email = "email@email.com",
    name = "app",
    options = {"build_exe": {"includes": includes,
                             "excludes": excludes,
                             "packages": packages,
                             "path": path
                            }
               },
    executables = [GUI2Exe_Target_1]
    )

关于我哪里出错的任何想法?

编辑:经过一些实验后,我试图使用的图标就会出现问题。如果我省略图标设置,它将构建。

1 个答案:

答案 0 :(得分:3)

显然cx_freeze希望图标采用.ico格式。如果您尝试使用.png作为图标,则构建过程将崩溃。此外,只需将文件扩展名从.png重命名为.ico不起作用,您实际上已将文件转换为ico。

这对某些人来说可能是显而易见的,但online docs没有详细说明图标所需的格式。