2

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?

4
  • Show us the code. Commented Dec 6, 2017 at 10:04
  • 1
    You run it with python3, but your error message talks about python2.7 Commented Dec 6, 2017 at 10:08
  • If I run it with Python 2.7, I get the same error message. Commented Dec 6, 2017 at 10:10
  • Why do you execute it as the superuser? Commented Aug 30, 2019 at 7:52

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.