Kevin Mueller
Kevin Mueller

Reputation: 668

Python Script Error When Executed In Terminal (Trutle Module)

So, I wrote a simple game, with the trutle module in Python. When I execute it, by doubleclicking it, it works just fine. But if I execute it in the Terminal, using sudo python3 SpaceWars.py it won't work.

Here's the error Message:

Error Message

I'm Sorry for the Picture. I was too lazy to retype the code.

Hardware / Software:

Machine: Raspberry PI 3 Model B

OS: Retropie (Based on Raspbian)

Python Version: Python 3.4.2 default [GCC 4.9.1 on linux]

Here's the Code: https://pastebin.com/ZERS2V9g

Can someone help me?

Upvotes: 2

Views: 95

Answers (1)

Armali
Armali

Reputation: 19395

The error message no display name and no $DISPLAY environment variable says it: it is unknown where to display the graphics. If the $DISPLAY variable was set, it got lost due to the sudo. You can try to preserve it by means of the -E (preserve environment) option:

sudo -E python3 SpaceWars.py

But the question remains whether you really have to execute it as the superuser.

Upvotes: 2

Related Questions