Home > Blockchain >  NameError: name 'display' is not defined
NameError: name 'display' is not defined

Time:02-04

I try to run python code using Linux terminal to display a png image.but it gives me same error again and again.

from PIL import Image
im=Image.open("/content/sample_1.png")

# Lets display the image

display(im)

CodePudding user response:

You could try using im.show() instead of display():

from PIL import Image
im=Image.open("/content/sample_1.png")

# Lets display the image

im.show()

CodePudding user response:

display is a command on the Linux shell, and you can't use in python directly.

If you just want to show the PNG image, you can use the following code:

import subprocess
im="/content/sample_1.png"
subprocess.getoutput("display %s" %im)
  • Related