2

I am running a raspberry pi3b+ via ssh. There is a hyperpixel4 screen by Pimoroni attached to the Pi and it's working fine. I am trying to display an image on the screen attached to the Pi with a python script via SSH.

I tried PIL and Pygame, but none works.

from PIL import Image
img = Image.open("image.jpg")
img.show()


import pygame #voor beeld en geluid
from time import sleep
from pygame.locals import *
pygame.init()
WIDTH = 1280
HEIGHT = 800
windowSurface = pygame.display.set_mode((WIDTH, HEIGHT), 0, 0)
img = pygame.image.load("ndvi.jpg")
windowSurface.blit(img, (0, 0))
pygame.display.flip()

With PIL, nothing happens at all. Even if I don't use SSH and type directly into the Pi's terminal. Pygame works if I type directly into the Pi (with a delay, but that can be solved with subprocess maybe). But it shows this error via ssh-"Unable to open a console terminal".

Thanks

0

Before you run your python script, run this:

export DISPLAY=:0.0

Then it should work as expected.

  • Thanks. It wakes up the display in case it has turned off due to inactivity. But it doesn't show the image. – Dhruv Jul 26 at 9:39
  • What if you do export DISPLAY=:0.0 ? – rm-vanda Jul 26 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.