Problem (solved) with PyQt and jpeg images

1,085 views
Skip to first unread message

Tom Sobota

unread,
Apr 11, 2013, 11:35:40 AM4/11/13
to portabl...@googlegroups.com
Hi all,

I found a problem with Portable Python and PyQt. My application refused to load a jpeg picture file in a QPixmap or in a QImage. I.e. pixmap = QPixmap('file.jpg') just refused to work. This was strange because in other contexts (non-portable Python install) it worked.

After a while, I found that the same problem has been described with python compilers such as py2exe or freeze. The problem is that at runtime Python cannot find the folder where the dlls for decoding image formats are. In PP, these dlls are in PP\App\Lib\site-packages\PyQt4\plugins.

In a non-portable installation the install path of PyQt4 can be found in the register, but this is not the case with P.P. There is a number of solutions proposed for this problem, some of which go against portability. I resolved the problem creating a qt.conf file in /PP/App. The file is like this:

[Paths]
Prefix = .
Binaries = .
Plugins = /PP/App/Lib/site-packages/PyQt4/plugins

This file actually exists somewhere in the PyQt folders, but it lacks the crucial Plugins entry. Also, I think that it works only in the App folder.
Not specifying the unit makes the configuration file slightly more portable but in certain circumstances it could fail. I wonder if there is a more generic solution to this problem.

Tom Sobota
Software developer
Madrid, Spain

 

Perica Zivkovic

unread,
Apr 11, 2013, 1:21:40 PM4/11/13
to portabl...@googlegroups.com
Thanks for reporting this, what version of PP are you using ?

Tom Sobota

unread,
Apr 11, 2013, 2:11:34 PM4/11/13
to portabl...@googlegroups.com
It's 2.7.3.2 . Actually I also installed PySide to see if the problem would go away, but no luck. The problem is the same with PyQt and PySide. I didn't verify if installing the qt.conf file in PySide would fix it too, probably yes.

Perica Zivkovic

unread,
May 12, 2013, 10:28:17 AM5/12/13
to portabl...@googlegroups.com
This is problem that seems to affect also other installed versions for some people, not only portable version.

I have played more with it and noticed that PNG files are loaded without problems as they don't require plugin.

You are right, in App/Lib/site-packages/PyQt4 there is qt.conf file that should by defaults pick up plugins as default value for Plugins (if you don't specify it) is "plugins" folder.

Workaround for portable version is to put qt.conf file in the App folder (next to python.exe) with following content

[Paths] 
Prefix = . 
Binaries = . 
Plugins = ./Lib/site-packages/PyQt4/plugins

with this I was able to load jpeg's and gif's without problem.

please let me know does this help, I will include this fix in the next release.

keep pythoning !

Perica Zivkovic

unread,
May 15, 2013, 4:48:26 PM5/15/13
to portabl...@googlegroups.com
This fix is included in just released 2.7.4.1 

Tomas Sobota

unread,
May 15, 2013, 6:06:53 PM5/15/13
to portabl...@googlegroups.com
Good. Thanks!
Tom



--
--
You received this message because you are subscribed to the Google Groups "PortablePython" group.
To post to this group, send email to portabl...@googlegroups.com
To unsubscribe from this group, send email to portablepytho...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/portablepython?hl=en
---
You received this message because you are subscribed to the Google Groups "PortablePython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to portablepytho...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages