If you are running Kubuntu or another distro that uses a KDE desktop you may not be able to view your work while using the Python Imaging Library (PIL) within a Python shell using the show() method.
I ran across this problem before but had long forgotten the solution and it isn't easy to Google a solution, so this post if for anyone having a similar problem which will probably be me again in a few months and a hardware upgrade from now. You may not experience this problem if you have eog, gqview or more unlikely xv installed and installing them may also resolve this issue. This should be a common issue for anyone running only KDE. Here is an example:
This module is designed to open the "yourpic.png" image with one of four viewers known by PIL. The known viewers are eog, gqview, gwenview and xv. I haven't tested eog or gqview but gwenview chokes on the temporary PIL file with the following error:
"Gwenview cannot display documents of type application/octet-stream."
It may be possible to fix that issue with Gwenview but I don't have the knowledge to get it to work. The problem with xv is that it is proprietary. If you don't have a problem with that it is available at no cost, but I haven't tried that either.
What finally did work for me is going into the PIL Image.py module and changing the default list of known viewers. It is a simple fix but don't try this if you aren't comfortable with editing Python source code and sudo. These instructions are not a step by step recipe and simply installing the Eye of Gnome viewer may also work and you may prefer that method to fix this issue even if you have the skill to edit a module's source code.
First locate the source code for the PIL module. For me it was at /usr/share/pyshared/PIL/Image.py.
Search for "def _showxv(" you should find it on or near line 2069 in Image.py, the actual line you need to edit looks like this:
Just add your preferred viewer to the front of the list, it will use the first one it finds.
I used kuickshow but if you prefer you could also use the Imagemagick display command. Those are the only two I've tested but I'm sure there are more.
If you know an easy way to get Gwenview to stop choking on Netpbm PPM "rawbits" image data I'd be interested.
---
MyMiasma
I ran across this problem before but had long forgotten the solution and it isn't easy to Google a solution, so this post if for anyone having a similar problem which will probably be me again in a few months and a hardware upgrade from now. You may not experience this problem if you have eog, gqview or more unlikely xv installed and installing them may also resolve this issue. This should be a common issue for anyone running only KDE. Here is an example:
Code:
>>> import Image >>> im = Image.open("yourpic.png") >>> im.show()
"Gwenview cannot display documents of type application/octet-stream."
It may be possible to fix that issue with Gwenview but I don't have the knowledge to get it to work. The problem with xv is that it is proprietary. If you don't have a problem with that it is available at no cost, but I haven't tried that either.
What finally did work for me is going into the PIL Image.py module and changing the default list of known viewers. It is a simple fix but don't try this if you aren't comfortable with editing Python source code and sudo. These instructions are not a step by step recipe and simply installing the Eye of Gnome viewer may also work and you may prefer that method to fix this issue even if you have the skill to edit a module's source code.
First locate the source code for the PIL module. For me it was at /usr/share/pyshared/PIL/Image.py.
Search for "def _showxv(" you should find it on or near line 2069 in Image.py, the actual line you need to edit looks like this:
Code:
for cmd in ["eog", "gqview", "gwenview", "xv"]:
I used kuickshow but if you prefer you could also use the Imagemagick display command. Those are the only two I've tested but I'm sure there are more.
If you know an easy way to get Gwenview to stop choking on Netpbm PPM "rawbits" image data I'd be interested.
---
MyMiasma
Comment