1
我是cx_Freeze的新手。 我開始在一個大的python應用程序中使用它。該應用程序使用PySide並使用多處理。在應用程序啓動時,每次啓動一個線程時,我都會看到一個cmd窗口很快閃爍(只需打開和關閉,非常快......沒時間讀任何東西)。 現在我嘗試了一個非常簡單的應用程序。像這樣:即使使用Win32GUI,cx_Freeze也會閃爍一個cmd窗口
import os
import sys
import multiprocessing
from PySide import QtGui
from PySide import QtCore
from PySide import QtNetwork
if __name__ == '__main__':
# multiprocessing support
multiprocessing.freeze_support()
# init application
app = QtGui.QApplication.instance()
if not app:
app = QtGui.QApplication(sys.argv)
QtGui.QApplication.setQuitOnLastWindowClosed(False)
# check systemtray
if not QtGui.QSystemTrayIcon.isSystemTrayAvailable():
QtGui.QMessageBox.critical(None, "Systray", "I couldn't detect any system tray on this system.")
sys.exit(1) # quick kill
wid = QtGui.QWidget()
wid.resize(250, 150)
wid.setWindowTitle('Simple')
wid.show()
sys.exit(app.exec_())
但是這仍然顯示並在開始時閃爍窗口。 下面是安裝文件我這個使用方法:
from cx_Freeze import setup, Executable
# dependencies
build_exe_options = {
"packages": [#"os", "sys", "glob", "re", "atexit",
"PySide.QtCore", "PySide.QtGui", "PySide.QtXml", 'PySide.QtXml',
'xml', 'P4', 'MYRefs_module', 'MYUtils_module', 'logging',
'multiprocessing'],
# "include_files": mfiles, # this isn't necessary after all
"excludes": ["Tkinter", "Tkconstants", "tcl"],
"build_exe": "build",
"icon": "img/icon.ico",
"include_msvcr":True
}
executable = [
Executable("main.pyw",
base="Win32GUI",
initScript = None,
targetName="Example.exe",
targetDir="build",
copyDependentFiles=True,
)
]
setup(
name="Example",
version="0.1",
description="Example", # Using the word "test" makes the exe to invoke the UAC in win7. WTH?
author="Me",
options={"build_exe": build_exe_options},
executables=executable,
requires=['PySide', 'cx_Freeze', 'P4', 'xml']
)
可能是我做錯了什麼?多處理是否支持這個問題?任何暗示讚賞。 順便說一句,我使用python 2.7.3x64和cx_Freeze 4.3.4,PySide 1.2.2 ...
如果你確實需要從Python中刪除一個目錄,有[shutil.rmtree](https://docs.python.org/3/library/shutil.html#shutil.rmtree)。 –