Forums

How to show an image in my python code

I am writing my first python script and all I want to do is display an image. I am using pythonanywhere on my chromebook, and here is the script I am running:

from PIL import Image
im=Image.open("img.png")
im.show()

Here is the error I am getting - unable to open X server `' @ error/display.c/DisplayImageCommand/432.

Any ideas on how to fix this? I think the error happens in the 3rd line of code because I tried to execute this code line by line in the Python terminal and the error happened in line number 3.

Any help will be much appreciated!

There is no display attached to our servers where you run your code.