Question

I'm trying to freeze a python 3.2.2 script with cx_freeze 4.2.3. PyQt4 is used by the source script, I'm not sure if that is a potential source of the issue. Python crashes during the build process. Here is the command line output:

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

running build

running build_exe

copying C:\Python32\Lib\site-packages\cx_Freeze\bases\Win32GUI.exe -> build\exe.win32-3.2\app.exe

copying C:\WINDOWS\system32\python32.dll -> build\exe.win32-3.2\python32.dll

Python itself crashes in Windows at this point and gives the "send error report" MS dialog:

python.exe has encountered a problem and needs to close. We are sorry for the inconvenience.

Here is my setup.py file:

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]
    )

Any ideas on where I'm going wrong?

edit: After some experimentation it appears the icon I am trying to use is causing issues. It will build if I leave out the icon setting.

Était-ce utile?

La solution

Apparently cx_freeze wants icons to be in .ico format. If you try to use a .png for an icon the build process will crash. Also, simply renaming the file extension from .png to .ico does not work, you have actually convert the file to ico.

This may have been obvious to some people but the online docs don't go into detail about required formats for icons.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top