Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

You must login to add post.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Passionable Logo Passionable Logo
Sign InSign Up

Passionable

Passionable Navigation

  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • New Questions
  • Trending Questions
  • Must read Questions
  • Hot Questions
Home/ Questions/Q 1524
In Process
Alek Richter
  • 0
Alek RichterEnlightened
Asked: November 3, 20212021-11-03T04:31:52+00:00 2021-11-03T04:31:52+00:00

Error when attempting to create Python GUI using Tkinter: “no display name and no $DISPLAY environment variable”

  • 0

Sup,

  • I am simply trying to use Tkinter (a Python GUI creator) to create a GUI on my Raspberry Pi.
  • To start, I only want a GUI to show up on my screen. That’s it!
  • The code DOES work on my PC
  • The code does NOT work on my Raspberry Pi

The entire script looks as follows:
(works on my PC, bringing up an empty GUI)

import Tkinter

root = Tkinter.Tk()

root.mainloop()

Trying to run the program in terminal as follows:

sudo python GUI.py

Produces the following error:

Traceback (most recent call last):

File “GUI.py”, line 4, in root = Tkinter.Tk()

File “/usr/lib/python2.7/lib-tk/Tkinter.py”, line 1817, in init

self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)

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

Does anybody have any idea how I can resolve this issue? The error is produced under all of the following conditions:

  • Direct HDMI to computer monitor
  • DSI connection to touchscreen LCD
  • SSH on computer monitor

For reference, if I type the following into my terminal:

echo $DISPLAY


An empty string gets printed, so I believe therein lies the problem

The following commands don’t work either, which might shed light on the problem:

sudo apt-get update

startx

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
    • Report
  • Share
    Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
    • Share on WhatsApp

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Alek Richter Enlightened
    2021-11-03T04:32:19+00:00Added an answer on November 3, 2021 at 4:32 am

    I solved it with these two commands:

    export DISPLAY=0.0
    xhost +

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 4k
  • Best Answers 0
  • Users 200
  • Popular
  • Answers
  • Alek Richter

    How do I update/upgrade pip itself from inside my virtual ...

    • 2 Answers
  • Alek Richter

    Truth value of a Series is ambiguous. Use a.empty, a.bool(), ...

    • 2 Answers
  • Alek Richter

    What is a NullPointerException, and how do I fix it?

    • 2 Answers
  • Alek Richter
    Alek Richter added an answer Pandas DataFrame columns are Pandas Series when you pull them… January 13, 2022 at 2:21 pm
  • Alek Richter
    Alek Richter added an answer The handshake failure could have occurred due to various reasons:… January 13, 2022 at 2:19 pm
  • Alek Richter
    Alek Richter added an answer Mac OS X doesn't have apt-get. There is a package… January 13, 2022 at 2:18 pm

Top Members

Alek Richter

Alek Richter

  • 4k Questions
  • 1k Points
Enlightened
fayemolloy0

fayemolloy0

  • 0 Questions
  • 20 Points
Begginer
NikolaZex

NikolaZex

  • 0 Questions
  • 20 Points
Begginer

Trending Tags

questin question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • New Questions
  • Trending Questions
  • Must read Questions
  • Hot Questions

© 2021 Passionable. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.