tkinter in Ubuntu inside Windows 10. Error: "no display name and no $DISPLAY environment variable"
Solved:
Note: This is when using the Ubuntu App inside Windows 10
Install Xming X server for Windows.
During installation there is an option to set the display to 0.
Add the line export DISPLAY=:0;
to .bashrc
as suggested.
I was having the same problem. I recently installed the 'Bash on Ubuntu on Windows' app from the store, and I was getting the following error when running my python script that tries to create a python UI:
_tkinter.TclError: no display name and no $DISPLAY environment variable
I followed @Zach instructions however my problem still remained. This is how I fixed my issue after following @Zach.
- I first installed Xming X Server for Windows.
- I then went into my home directory
~
on the Ubuntu terminal, and opened my .bashrc file by executingvim .bashrc
. - At the end of the file, I added the following line:
export DISPLAY=:0;
. Instead of 'execute', I used 'export'.
Make sure to close all terminal instances before trying to execute the python script.
And that worked for me!
If you don't want to install Xming X Server For Windows
Then use CMD in windows and it will work fine.