0

In a .py file this line states "screen = pygame.display.set_mode ( (1, 1) )". It yields an error "error code in python--pygame.error: Unable to open a console terminal". Can someone suggest a solution?

1
  • 1
    Are you using Raspberry Pi OS with Desktop? Some complete runnable code would help. – CoderMike Oct 10 '20 at 12:45
1

Are you trying to run a graphical program over ssh or with putty?

If so you either need to use vnc or run directly on the Pi within the Desktop.

1
  • Thanks CoderMike. Running from ssh.. Have not tried vnc or running on the Pi Desktop. Will try both methods. Thanks again. – RoboNovice Oct 12 '20 at 14:54
0

If you are trying in invoke a pygame window remotely over ssh, then make sure you specify the 'display' environment variable inside your code like this:

os.environ["DISPLAY"] = ":0"
pygame.display.init()

Note 'display' is not always ':0.0' but most of the time it is. You can find it by opening a local terminal window and typing 'echo $DISPLAY'

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.