In a PyQT4 program, I have a QLabel displaying an image with the following code :
in the init code :
Image=QImage(som_path_from_a_fileDialog)
in the resize method :
pixmap = QPixmap.fromImage(Image)
pixmap = pixmap.scaled(self.display.size())
self.display.setPixmap(pixmap)
When I execute my script with python, it works fine, and I can display .bmp and JPEG files.
If I compile it using py2exe however, I will only be able to display .bmp files.
JPEG File display will fail with :
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::end: Painter not active, aborted
QPixmap::scaled: Pixmap is a null pixmap
EDIT :
It is a duplicate of this question
Support for many image formats in recent versions of PyQt4 available via plugins. These plugins could be found in your
C:\PythonXY\Lib\site-packages\PyQt4\plugins\imageformatsdirectory. You should copyimageformatsdirectory to the directory with your exe. Please note, that you need to haveimageformatsdirectory right along the your pyapp.exe. Or you should put in the same directory where is your pyapp.exe located special qt.conf where you can specify the path to the image plugins, e.g.Here is example of the code to copy sqlite plugin (it’s not for images, but you will get the idea) when I built my exe: