Problem with PyInstaller & PySide - Loss of image formats

423 views
Skip to first unread message

Pierre Adam

unread,
Mar 7, 2014, 12:12:14 PM3/7/14
to pyins...@googlegroups.com
Hi,

I have a problem of image formats when i compile my file with PyInstaller

This is a very simple test file for printing all supported image format with PySide (with python 2.7 and PySide v1.2.1 on Windows 7)

#!/usr/bin/python
import PySide.QtGui as QtGui
print QtGui.QImageReader.supportedImageFormats()


with this command python test.py, I have :
[PySide.QtCore.QByteArray('bmp'), PySide.QtCore.QByteArray('gif'), PySide.QtCore.QByteArray('ico'), PySide.QtCore.QByteArray('jpeg'), PySide.QtCore.QByteArray('jpg'), PySide.QtCore.QByteArray('mng'), PySide.QtCore.QByteArray('pbm'), PySide.QtCore.QByteArray('pgm'), PySide.QtCore.QByteArray('png'), PySide.QtCore.QByteArray('ppm'), PySide.QtCore.QByteArray('tga'), PySide.QtCore.QByteArray('tif'), PySide.QtCore.QByteArray('tiff'), PySide.QtCore.QByteArray('xbm'), PySide.QtCore.QByteArray('xpm')]


I created a spec file for PyInstaller for compiling my test :
# -*- mode: python -*-
includeDll = ['.']
excludesFiles =  []
a = Analysis(['Test.py'], pathex=includeDll, excludes = excludesFiles)
pyz = PYZ(a.pure)
exe = EXE(pyz, a.scripts, a.dependencies, exclude_binaries=1, name=os.path.join('dist', 'Test.exe'), debug=True, strip=None, upx=True, console=True )
coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=None, upx=False, name=os.path.join('dist', 'Test'))


The EXE file is correctly created and when I launch it, i have :
[PySide.QtCore.QByteArray('bmp'), PySide.QtCore.QByteArray('pbm'), PySide.QtCore.QByteArray('pgm'), PySide.QtCore.QByteArray('png'), PySide.QtCore.QByteArray('ppm'), PySide.QtCore.QByteArray('xbm'), PySide.QtCore.QByteArray('xpm')]

Consequently, I lost gif, ico, jpeg, jpg, mng, tga, tif, and tiff formats.

Any ideas ?

Thanks

Pierre

Martin Zibricky

unread,
Mar 10, 2014, 5:20:33 AM3/10/14
to pyins...@googlegroups.com
On Friday 07 of March 2014 09:12:14 Pierre Adam wrote:
> Consequently, I lost gif, ico, jpeg, jpg, mng, tga, tif, and tiff formats.
>
> Any ideas ?

The issue is that PySide is not fully supported by pyinstaller. There are
missing import hooks for that.

And that there are issues with image formats means that pyinstaller does not
include qt plugins.

Look at PyQt4 hooks and how there are qt plugins and dependencies handled.
Something similar is required for PySide to work.
signature.asc

James Ramm

unread,
May 7, 2014, 6:06:34 AM5/7/14
to pyins...@googlegroups.com
Hi
I have sucessfully built numerous pyside applications with pyinstaller.

For images, the best method is to create qt resource files. There is a good explanation here:

http://stackoverflow.com/questions/11534293/pyinstaller-wont-load-the-pyqts-images-to-the-gui

In the end, your application should have a file called something like images.qrc and another python file built by pyside-rcc.exe called images.py which you import where you need your images. Access your images using a relative path with a colon before the path. e.g:

QtGui.QIcon(':/images/myImage.png')

The only thing I would add is that the 'Tree' command the answer says is required in the .spec file is 100% not necessary. No changes required to the .spec file.
Reply all
Reply to author
Forward
0 new messages