Images that are not displayed when running frozen pyqt application on another computer

I have a PyQt4 program that I froze with cx_freeze. The problem I am facing is that when I create a QGraphicsPixmapItem that gets its "pixmap" from the SVG file, the element gets no problems, but the Pixmap doesn’t load, so there’s no image only of the element in the scene, What confuses me is that this only happens when I run it on a different computer than the one that exe built. When I run exe on the computer that built it, the program works fine. Even when I try to run it on a computer with all the necessary python components and pyqt components installed on the computer, if this is not the computer that created it, pixmap does not load from the svg file. I'm not sure if this is a problem with my setup.py cx_freeze file, or if I need to change something in the main code, so any help or just pointing me in the right direction would be great. I feel like something gets messy when cx_freeze creates it, so I am pasting the contents of my setup.py file below. I also start Windows using Python v3.1.

from cx_Freeze import setup, Executable files = ['drawings\\FULL', 'drawings\\PANEL', 'data.csv', 'panelData.csv'] binIncludes = ['C:\\Python31\\Lib\\site-packages\\PyQt4\\bin\\QtSvg4.dll'] includes = ['main', 'PunchDialog', 'ArrayDialog', 'PricingDialog', 'FontAndInputDialog', 'PanelSelector', 'PyQt4', 'os', 'sys', 'ctypes', 'csv'] packages = ['drawings'] path = ['C:\\Users\\Brock\\Documents\\Programming\\PanelDesigner\\DrawingFirst', 'C:\\Python31\\Lib', 'C:\\Python31\\Lib\\site-packages', 'C:\\Python31\\DLLs'] setup( name = 'PanelBuilder', version = '1.0', description = 'Allows user to draw custom panel layouts.', author = 'Brock Seabaugh', options = {'build_exe': {'packages':packages, 'path':path, 'include_files':files, 'bin_includes':binIncludes, 'includes':includes}}, executables = [Executable('PanelBuilder.py')]) 

PS. Here is my file hierarchy (if that helps at all):

 \DrawingFirst Main .py file All .py files for all custom dialogs used \drawings some modules used \FULL A bunch of SVG files used \PANEL More SVG files used 
+4
source share
3 answers

This is an unpleasant problem that I encountered in the past. Let me quote http://www.py2exe.org/index.cgi/Py2exeAndPyQt : (I know you are using cx_freeze, but I'm sure you can adapt your script)

PyQt4 and image upload (jpg, gif, etc.)

PyQt4 uses plugins to read these image formats, so you will need to copy the PyQt4 \ plugins \ imageformats folder for AppDir \ imageformats. As in the above, you can use data_files for this. This will not work with bundle_files on.

If plugins are not available, QPixmap.load / loadFromData will return incorrectly when loading images in those formats.

testapp.py:

 from PyQt4 import QtGui, QtSvg import sys app = QtGui.QApplication([]) wnd = QtSvg.QSvgWidget() wnd.load("flower.svg") wnd.show() sys.exit(app.exec_()) 

setup.py:

 from cx_Freeze import setup, Executable files = ['flower.svg'] includes = ['sip', 'PyQt4.QtCore'] setup( name = 'Example', version = '1.337', description = 'Allows user to see what I did there.', author = 'something', options = {'build_exe': {'include_files':files, 'includes':includes}}, executables = [Executable('testapp.py')]) 

I created this test application on a computer running Windows 7 and copied it to a computer running Windows XP. I did not need to copy any DLL files - it worked just like that.

+6
source

I added a binding to cx_freeze , which includes imageformats when PyQt4.QtGui included in the source code. With imageformats , icons stored externally even work in the right place.

https://bitbucket.org/anthony_tuininga/cx_freeze/pull-request/11/added-pyqt4qtgui-load-hook-that-adds/diff

+3
source

For people coming here from Google: if you use only QtWebKit, you need to copy the imageformats directory (which you will find in PYTHONDIR \ lib \ site-packages \ PyQt4 \ plugins) to the application directory. Specifying PyQt4.QtWebKit among the inclusions is not enough.

0
source

All Articles