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")

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

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


  • Does the image is shown if you are direct logged in to the RasPi using an attached keyboard?
    – Ingo
    Commented May 22, 2020 at 8:33

1 Answer 1


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
    Commented Jul 26, 2019 at 9:39
  • What if you do export DISPLAY=:0.0 ?
    – rm-vanda
    Commented Jul 26, 2019 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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