Cx_Freeze / py2exe Qt5.5.1应用程序

时间:2016-05-23 13:20:28

标签: qt python-3.x pyqt py2exe cx-freeze

我使用QtDesigner设计GUI并使用pyuic5生成python代码。使用cxfreeze或py2exe冻结它后,app会在setupUI函数崩溃,这是pyuic5生成的。从代码运行应用程序时,它按预期工作。我使用python 3.4(在Anaconda Distribution内)和Qt 5.5.1

app brokes的第一段代码(在主UI的setupUI方法上):

#Add a QWidget to QTabWidget
self.ModuleListingWidget.addTab(self.MarketingTab, "")

当我使用dependencywalker并尝试分析生成的exe时,它会记录以下错误:

00:00:00.000: Started "dist\MAIN.EXE" (process 0x2938) at address 0x000C0000.  Cannot hook module.
00:00:00.000: Loaded "c:\windows\system32\NTDLL.DLL" at address 0x772C0000.  Cannot hook module.
00:00:00.047: Loaded "c:\windows\syswow64\KERNEL32.DLL" at address 0x76CA0000.  Cannot hook module.
00:00:00.047: Loaded "c:\windows\syswow64\KERNELBASE.DLL" at address 0x74BF0000.  Cannot hook module.
...
00:00:00.125: First chance exception 0xC0000005 (Access Violation) occurred at address 0x721E5B10.
00:00:00.125: Second chance exception 0xC0000005 (Access Violation) occurred at address 0x721E5B10.

py2exe和cxfreeze都给出了相同的错误,0xC0000005(访问冲突)。

我如何解决这个问题,或者更多地了解问题本身?

这是cxfreeze配置:

import sys
from cx_Freeze import setup, Executable

base = "Win32GUI"
path_platforms = ( ".\platforms\qwindows.dll", "platforms\qwindows.dll" )
build_options = {"packages": ['atexit'], "include_files" : [ path_platforms ]}

setup(
    name = "myapp",
    version = "0.1",
    description = "Sample cx_Freeze script",
    options = {"build_exe" : build_options},
    executables = [Executable("main.py", base = base)]
    )

和py2Exe config:

from distutils.core import setup
import py2exe
import sys
sys.argv.append('py2exe')
import glob
import src.MyProj
setup(console=['main.py'], options = {"py2exe": {"typelibs":
                          # typelib for WMI
                          [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)],
                          # create a compressed zip archive
                          "compressed": True,
                            'bundle_files':   1,
                          "optimize": 2,

                          "includes":['sip', "PyQt5", 'PyQt5.QtCore', 'PyQt5.QtWidgets', 'PyQt5.QtGui',  'PyQt5.QtSql']}},

    # The lib directory contains everything except the executables and the python dll.
    # Can include a subdirectory name.
    zipfile = "./shared.zip",
      data_files=[
          ('Images', glob.glob('Images/*.*')),
            ('sqldrivers', ('C:/Users/user/src/dist/plugins/qsqlmysql.dll',)),

                ('/c/Python34/Lib/site-packages/PyQt5', ['C:/Python34/Lib/site-packages/PyQt5/Qt5Core.dll'])])

1 个答案:

答案 0 :(得分:0)

我无法找到并解决这个问题,可能是依赖错误。相反,我使用了pyinstaller,它就像魅力一样。