要在 PyQT 应用程序中启用 jpeg 支持,您必须手动包含qjpeg4.dll
.
当 dll 和 pyd 文件没有在最终的 exe 中捆绑在一起时,它可以正常工作。例如,使用 py2exe 您可以执行以下操作:
DATA=[('imageformats',['C:\\Python26/Lib/site-packages/PyQt4/plugins/imageformats/qjpeg4.dll'])]
setup(console=[{"script":"cycotic.py"}],
data_files = DATA,
options={"py2exe":{
"includes":["sip"],
"excludes":MODULE_EXCLUDES,
"bundle_files":3,
"compressed":False,
"xref":True}},
zipfile=None)
但是,如果您做同样的事情,并将 dll 捆绑在 exe 中(使用"bundle_files":1
),则会失败并显示以下消息:
QObject::moveToThread: Current thread (0x3a16608) is not the object's thread (0x
2dddaf8).
Cannot move to target thread (0x2dddaf8)
QObject::moveToThread: Current thread (0x3a16608) is not the object's thread (0x
2dddaf8).
Cannot move to target thread (0x2dddaf8)
QObject::moveToThread: Current thread (0x3a16608) is not the object's thread (0x
2dddaf8).
Cannot move to target thread (0x2dddaf8)
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::end: Painter not active, aborted
QPixmap::scaled: Pixmap is a null pixmap
如何正确捆绑应用程序?