2010-02-05 14 views
0

要在PyQT应用程序中启用jpeg支持,您必须手动包含qjpeg4.dll
当最终的exe文件没有将dll和pyd文件捆绑在一起时,它工作正常。例如 与py2exe,你可以做到以下几点:pyqt jpeg支持不以捆绑形式工作

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) 

但是,如果你做同样的事情,而你在exe文件捆绑的DLL(使用"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 

如何正确捆绑应用程序?

回答

0

尝试增加pyqt4作为一揽子迫使py2exe包括在您构建了从PyQt的,就像这样:

options={"py2exe":{ 
     "includes":["sip"], 
     "excludes":MODULE_EXCLUDES, 
     "packages":["PyQt4"], 
     "bundle_files":1, 
     "compressed":False, 
     "xref":True}} 
+0

修改pyqt - > PyQt4有一个有效的包名称,但失败了。显然PyQt4不喜欢被包含这种方式。它失败: 错误:编译'C:\ Python26 \ lib \ site-packages \ PyQt4 \ uic \ port_v3 \ proxy_base.py' 失败 SyntaxError:无效语法(proxy_base.py,第4行) – shodanex 2010-02-08 14:53:41

+0

这是一个proxy_base.py中的错误?将proxy_base添加到您的Excludes并查看它是否构建 – 2010-02-08 15:30:26

2

我有同样的问题,据我所知,py2exe提供了线索: http://www.py2exe.org/index.cgi/Py2exeAndPyQt

它显示为: ......所以您需要将文件夹PyQt4 \ plugins \ imageformats复制到\ imageformats。 ....... 这不适用于上的bundle_files。 ... *这也适用于bundle_files,但您需要从捆绑包中排除Qt DLL(使用dll_excludes选项),并使用其他机制(如data_files)将其添加到包含可执行文件的目录中。 *

以下是我的设置选项,如:

zipfile=None, 
    options = { "py2exe" :{ 
          "compressed":1, 
          "includes": my_includes,       
          "packages": my_packages, 
          "optimize":2, 
          "bundle_files":1, 
          "dll_excludes":["QtCore4.dll","QtGui4.dll","QtNetwork4.dll"] 
          }} 

所以dist文件夹包含这些文件(在我的情况):

  • imageformats(文件夹,包括QT插件的DLL来处理图像)
  • QtCore4.dll
  • QtGui4.dll
  • QtNetwork4.dll
  • MyExeFile.exe
  • w9xpopen.exe

这一切