Skip to content
← Back to Community
Is it possible to use PIL in repl.it to show images?
Profile icon
boukeas

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 [earned 5 cycles]
View Answer
Voters
Profile icon
Redboyx9
Profile icon
BertLindeman
Profile icon
Sachin9
Profile icon
benldn
Profile icon
boukeas
Comments
hotnewtop
Profile icon
Scoder12

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.

Profile icon
boukeas

@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.

Profile icon
Scoder12

@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().