Image.show() won't display the picture

I'm running a python script but it won't show the picture.

I have an apple.jpg image in a directory with this program and it should show the picture, but it doesn't. Here is the code:

#!/usr/bin/env python

from PIL import Image

Apple = Image.open("apple.jpg")
Apple.show()

My OS is Ubuntu and this program just gets completed without showing any error.


It works for me on Ubuntu. It displays the image with Imagemagick. Try this:

sudo apt-get install imagemagick

I know, it's an old question but here is how I fixed it in Ubuntu, in case somebody has the same problem and does not want to install imagemagick (which does not fix the root cause of the problem anyway).

The default viewer on Ubuntu can be started using the command "eog" in the terminal. Pillow, by default, searches only for the commands "xv" and "display", the latter one being provided by imagemagick. Therefore, if you install imagemagick, calling "display" will indeed open up the image. But why not use the viewer that we already have?

The Python code to open the viewer can be found in lib/python3.4/site-packages/PIL/ImageShow.py (or the equivalent of your Python installation). Scroll down to below line# 155 and find the code block saying:

class DisplayViewer(UnixViewer):
    def get_command_ex(self, file, **options):
        command = executable = "display"
        return command, executable

if which("display"):
    register(DisplayViewer)

Copy that block and paste it right underneath, changing the "display" command to Ubuntu's "eog" command:

class DisplayViewer(UnixViewer):
    def get_command_ex(self, file, **options):
        command = executable = "eog"
        return command, executable

if which("eog"):
    register(DisplayViewer)

After saving ImageShow.py, Pillow should correctly show() images in the default viewer.


This is an old question, however, it has bugged me for a while. This is my solution:

I run Python 2.7 on Linux Mint and when calling Image.show() nothing happens. On my system, the default viewer is "Image Viewer", which is called "eog" in bash. My Python thinks that I use something else maybe "xv". So, open a terminal and run

sudo gedit /usr/lib/python2.7/dist-packages/PIL/ImageShow.py

Search for "xv" and replace it with "eog".

Save the file and Image.show() works fine (for debugging purposes).