1

I have a RaspberryPi with a PiTFT 3.5 display connected. The display is configured to mirror the HDMI output and the Pi is running Raspbian desktop.

Now what I am trying to do is to run a python program on the desktop but start it over the ssh connection. The problem is that when I just run my python script over the terminal as such:

sudo python3 /usr/local/project/main.py

it gives the following error:

_tkinter.TclError: no display name and no $DISPLAY environment variable

So is there a way of starting the python program on the desktop through ssh or maybe passing the display variable to Tkinter so that the program displays on my PiTFT screen.

asked Sep 18, 2019 at 14:54

1 Answer 1

1

Before you launch the script from ssh:

export DISPLAY=:0

There are other possible values but, presuming there is only one GUI user logged in on the pi, it will be :0, the first display. You can also get it directly from the desktop (echo $DISPLAY) -- but not from the ssh login.

answered Sep 18, 2019 at 17:14
2
  • Perfect it works, the only thing I had to change is to not run it as superuser and run your command and then it worked perfectly. Commented Sep 19, 2019 at 7:54
  • $DISPLAY is an environment variable, if you are curious. The export command is a shell built-in. Commented Sep 19, 2019 at 10:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.