Ask coding questions

← Back to all posts
Is it possible to use PIL in repl.it to show images?
boukeas (1)

It seems PIL can no longer be imported from "regular" Python repls.
It can be imported in Tkinter repls but Image.show() produces no output.
Is there a way to make this work, i.e. display an image in the output window?

Answered by Scoder12 (875) [earned 5 cycles]
View Answer
Comments
hotnewtop
Scoder12 (875)

If you save the image to a file using img.save('whatever.png') (with whatever filename you want), then it should pop up below the console, even if it doesn't you can click on it and view it.

boukeas (1)

@Scoder12 thank you for your reply. I have read about this workaround in older posts, but I was just wondering whether this might have been resolved in the meantime. Repl.it is now able to display graphics in the Tkinter, Pygame and Turtle "flavours", so I was hoping that PIL.show would also somehow work.

Scoder12 (875)

@boukeas oh ok. The way that Image.show() works is by saving the file to a temporary filename and calling xv to show the image, which requires the X window system to be running, which is not. If you want to show the image via Tkinter or Pygame you would probably have to implement that yourself rather than using show().