2014-01-19 99 views
1

當我編譯我的文件(snake.py)爲exe,輸出文件(exe文件)不起作用。 我想這可能是因爲發生的錯誤而導致編譯期間:exe文件無法正常工作(沒有任何反應)

missing modules: 
? _frozen_importlib imported from importlib 

enter image description here

任何想法?

import sys 
from cx_Freeze import setup, Executable 

base = None 
if sys.platform == "win32": 
     base = "Win32GUI" 

setup(
    name = "simple_PyQt4", 
    version = "0.1", 
    description = "Sample cx_Freeze PyQt4 script", 
    options = {"build_exe" : {"includes" : "atexit" }}, 
    executables = [Executable("hello_qt.py", base = base)]) 
+0

你用什麼工具「編譯」exe文件? – Fenikso

+0

exe給出了什麼錯誤?它究竟如何「不起作用」? – Fenikso

+0

建立exe的設置是什麼?你能成功構建「hello_world.py」嗎?你能成功地構建「hello_qt.py」嗎? – Fenikso

回答

1

我用PySide,但它應該幾乎等於你的PyQt。

我有這樣的代碼hello_pyside.py

import sys 
from PySide.QtCore import * 
from PySide.QtGui import * 

class Window(QWidget): 
    def __init__(self, *args, **kwargs): 
     QWidget.__init__(self, *args, **kwargs) 

     self.button = QPushButton("Test", self) 
     self.button.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) 

     self.layout = QHBoxLayout() 
     self.layout.setContentsMargins(5, 5, 5, 5) 
     self.layout.addWidget(self.button) 

     self.setLayout(self.layout) 
     self.show() 

app = QApplication(sys.argv) 
win = Window() 
sys.exit(app.exec_()) 

我叫安裝了cx_freeze此腳本:

c:\Python33\Scripts\cxfreeze.bat hello_pyside.py --target-dir=Bin/pyside --base-name=Win32GUI --target-name=hello_pyside.exe --include-modules=re --exclude-modules=Tkinter 

我也得到包含目錄:

_bz2.pyd 
hello_pyside.exe 
PySide.QtCore.pyd 
PySide.QtGui.pyd 
pyside-python3.3.dll 
python33.dll 
QtCore4.dll 
QtGui4.dll 
shiboken-python3.3.dll 
unicodedata.pyd 

這應該做工精細。