我有一个控制台' hello world'使用cx_freeze对exe编译好的app ...现在我想对基于pyqt gui的程序做同样的事情。
我已经删除了所有导入的模块,现在只有一个最小的cxtest.py文件(注意,从IDLE执行时它会正确显示gui窗口):
#python General Packages
import sys
#import time #time.sleep(sec float) , qApp.processEvents();
#import ctypes as ct
#import pprint as p
#import threading, random, queue
#import pathlib
#import winreg
#import itertools
#import struct
from PyQt4 import (QtCore, QtGui, uic)
# OpenGL
#from OpenGL.GL import *
#from OpenGL.GLU import *
#import pygame
#from pygame.locals import *
#import serial
#from ComThreadFile import ComThreadClass
class MyWindowClass(QtGui.QDialog ):
def __init__(self, *args):
super(MyWindowClass, self).__init__(*args) #.__init__(parent)
# Set up the user interface from Designer.
uic.loadUi('Test.ui', self)
def main():
#Main Window App
qApp = QtGui.QApplication(sys.argv)
myWindowForm = MyWindowClass()
myWindowForm.show()
# *** START ***
qApp.exec_()
# *** END (exit isn't killing it?!) ***
# sys.exit(qApp.exec_())
if __name__ == "__main__":
main()
但是通过' python setup.py build'将它构建到.exe,其中setup.py是:
from cx_Freeze import setup, Executable
includes = ["atexit", "sip", "re", "PyQt4.QtCore"]
exe = Executable(
script = "cxtest.py",
base = "Win32GUI"
)
setup(
options = {"build_exe": {"includes": includes}},
executables = [exe]
)
它会生成&#c; cxtest.exe'但运行时出错:
File "C:\Python34\Lib\site-packages\cx_Freeze\initscripts\Console.py", line 28, in <module> exec(code, m.__dict__)
File "cxtest.py", line 13, in <module>
File "C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2213, in _find_and_load
...