【发布时间】:2023-04-01 02:02:01
【问题描述】:
我的 PyQt4 应用程序的 py2exe 二进制文件在屏幕上短暂闪烁然后消失。我不知道为什么,但这是之前发生的事情:
我的应用程序在加载(来自 Exe)时没有显示 SVG 图像,所以我挖掘了一下,发现我必须修改我的 setup.py 以包含 qt.conf 和一些 DLL。
然后在包含qt.conf 之后,二进制文件就停止了加载。
我玩了qt.conf,发现我的Exe无法加载除非我删除了qt.conf,所以我认为它格式错误。
这是我的qt.conf:
[Paths]
Plugins = plugins
我尝试过使用绝对路径、正斜杠、反斜杠,应有尽有。我什至用这个文件复制了整个 PyQt4 文件夹,但仍然没有运气。
如果相关,这里是我的setup.py:
import os, sys, glob
from distutils.core import setup
from py2exe.build_exe import py2exe
def find_data_files(source,target,patterns):
if glob.has_magic(source) or glob.has_magic(target):
raise ValueError("Magic not allowed in src, target")
ret = {}
for pattern in patterns:
pattern = os.path.join(source,pattern)
for filename in glob.glob(pattern):
if os.path.isfile(filename):
targetpath = os.path.join(target,os.path.relpath(filename,source))
path = os.path.dirname(targetpath)
ret.setdefault(path,[]).append(filename)
return sorted(ret.items())
setup(
# zipfile = None,
data_files = find_data_files('', '', ['bin/*', 'plugins/iconengines/*', 'qt.conf']),
windows = [{'script': 'main.py'}],
# cmdclass = {'py2exe': Py2exe},
options = {
'py2exe': {
'bundle_files': 1,
'includes': ['sip'],
'dll_excludes': ['MSVCP90.dll']#, 'qsvgicon4.dll']
}
}
)
【问题讨论】: