【发布时间】:2017-02-21 23:56:49
【问题描述】:
我正在尝试冻结我的 Python 应用程序,并且在同时使用 Cx_Freeze 和 Py2Exe 时遇到了同样的问题。一旦我构建/冻结了代码,我就会启动可执行文件并在屏幕上快速闪烁大约六个控制台(连续快速打开和关闭),直到我的 GUI 窗口(使用 PyQt5 创建)打开。一旦 GUI 窗口打开,一切似乎都运行良好。
注意:Dll 文件 DLL 文件似乎存在一个常见错误,我已经在 qwindows.dll 文件以及 libEGL.dll 文件中包含了一个名为平台的文件夹,该文件与可执行文件直接位于同一文件夹中。我不认为这是相关的,但是因为我能够真正看到我的初始小部件。
这是我的 Cx_Freeze 的 setup.py 文件:
import sys
from cx_Freeze import setup, Executable
base = 'Win32GUI'
executables = [
Executable('__main__.py', base=base)
]
# Dependencies are automatically detected, but it might need fine tuning.
buildOptions = {"packages": [], "excludes": []}
#serial, requests, idna
setup(name = "Test",
version = "0.1",
description = "Manufacturing Testing Software",
options = dict(build_exe = buildOptions),
executables = executables)
这是我的 Py2Exe 的 setup.py 文件:
from setuptools import setup
import os
import py2exe
includes = ["sip",
"PyQt5",
"PyQt5.QtCore",
"PyQt5.QtGui",
"PyQt5.QtWidgets",
"PyQt5.QtWebKit",
"PyQt5.QtWebKitWidgets",
"PyQt5.QtWebKitWidgets",
"PyQt5.QtNetwork",
"PyQt5.QtPrintSupport"]
datafiles = [("platforms", [r"C:\Users\allan\AppData\Local\Continuum\Anaconda2\Library\plugins\platforms\qwindows.dll"]),
("", [r"c:\windows\syswow64\MSVCP100.dll",
r"c:\windows\syswow64\MSVCR100.dll",
r"C:\Python36-32\Lib\site-packages\PyQt5\Qt\bin\libEGL.dll"])]
setup(
name='Test',
version='1',
windows=['__main__.py'],
data_files = datafiles,
options={
"py2exe":{
"includes": includes,
}
}
)
【问题讨论】:
标签: console py2exe pyqt5 cx-freeze