1

So I'm trying to run a python GUI using tkinter from Ubuntu command line, on Windows 10, and get the following error:

brandon@DESKTOP-V5LTF5T:~$ python3 MainApp.py
Traceback (most recent call last):
  File "MainApp.py", line 14, in <module>
    root = tk.Tk()
  File "/usr/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

If you are using the matplotlib library then use this question: _tkinter.TclError: no display name and no $DISPLAY environment variable

However, this question is for people using the tkinter library only

notMyName
  • 690
  • 2
  • 6
  • 17
  • Have you searched this site for an answer. There are dozens of questions related to this error. – Bryan Oakley Jul 03 '20 at 16:00
  • What do you mean by "from Ubuntu command line, on windows 10". Ubuntu and Windows 10 are completely separate operating systems. – Bryan Oakley Jul 03 '20 at 16:00
  • @BryanOakley Yes, they deal with MatplotLib and Putty services, not purely tkinter applications and Ubuntu, running Ubuntu from windows – notMyName Jul 03 '20 at 16:01

1 Answers1

5

One cannot run active GUI's inside a bash terminal unless they download external software. The following tutorial is how I found out how to solve this problem: http://pjdecarlo.com/2016/06/xming-bash-on-ubuntu-on-windows-x11-window-system-running-from-windows-10-subsystem-for-linux.html

  1. Download xming x server: A free display server for windows operating systems, simply allows you to display gui's and other fancy things from terminals: This is where I found it: https://sourceforge.net/projects/xming/ , then run the server and it should appear in the lower right hand of the taskbar

  2. Run the following command from bash/ubuntu: brandon@DESKTOP-V5LTF5T:~$ export DISPLAY=localhost:0.0, this sets the DISPLAY variable to the local host of the newly installed xming x xerver.

  3. Now run your GUI! brandon@DESKTOP-V5LTF5T:~$ python3 MainApp.py

notMyName
  • 690
  • 2
  • 6
  • 17