Quantcast
Channel: Active questions tagged windows-subsystem-for-linux - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2827

having issues running tkinter

$
0
0

I have been trying to run simple tkinter from python in VSC via WSL and I have been having issues. The code works just fine when I am using regular Windows but when I try to run code via VSC using WSL I always receive a traceback error. I have looked through these forums but I cannot seem to find the answer. I have used sudo-apt get install python3-tk to install it via the terminal. I have tried to run the following code for a simple root window:

 from tkinter import * root = Tk() label = Label(root, text="I am a label widget") button = Button(root, text="I am a button") label.pack() button.pack() root.mainloop()

However, I receive the following traceback error:

Traceback (most recent call last):File "/home/letsgo/guipractice/guii.py", line 3, in root = Tk()File "/usr/lib/python3.8/tkinger_init_.py", line 2270, in initself.tik = >tkinter.create(screenName, baseName, className, interactove, wantobjects, useTk,, sync, use)_tkinger.TclError: no display name and no $DISPLAY environment variable

I am not sure what is going on. I know that I have Tkinter properly installed because I have checked for the version that I currently have via the terminal and it has shown 8.6. When I run from tkinter import * it runs just fine.

Help would be appreciate; thank you.


Viewing all articles
Browse latest Browse all 2827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>