pyqt4gui到exe使用py2exe添加python27.dll导致崩溃

2024-06-16 10:27:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我用PyQt4(PyQt4.QtGui和PyQt4.QtCore)创建了一个GUI,这个GUI包括使用matplotlib绘制图形,导入了我自己编写的几个模块,GUI还有一个图标。 我用的是Python2.7。在

我的模块与GUI.py在同一个目录中,icon.jpg也是。在

我的设置.py代码:

from distutils.core import setup
import py2exe, sys, os

import matplotlib as mpl
mpl.use('Qt4Agg') #I use this is GUI.py

sys.argv.append('py2exe')

includes = ['sip', 'PyQt4', 'PyQt4.QtGui', 'PyQt4.QtCore', 'matplotlib.backends']

excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'pywin.debugger',
            'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
            'Tkconstants', 'pydoc', 'doctest', 'test', 'wx']

packages = ['matplotlib'] #should my custom modules go in here?

dll_excludes = ["MSVCP90.dll", "MSWSOCK.dll", "mswsock.dll", "powrprof.dll",
            'libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
            "libgdk_pixbuf-2.0-0.dll"]

data_files = mpl.get_py2exe_datafiles()


setup(name = "main",
      windows = [{"script":"GUI.py", "icon_resources": [(1, "icon.jpg")]}],
      options = {'py2exe': {
          'compressed': True,
          'includes': includes,
          'excludes': excludes,
          'packages': packages,
          'dll_excludes': dll_excludes,
          'bundle_files': 1}},
      zipfile = None,
      data_files = data_files
)

问题是当我在cmd上运行python setup.py时,它会到达Adding python27.dll as resource,然后我得到一个错误消息python.exe已经停止工作。为什么会这样,我该怎么解决?在

另外,如果有其他事情我应该包括,或反过来排除,请告诉我他们是什么。在


Tags: pyimportmatplotlibpackagessetupguifilesmpl