no module named tkinter

no module named tkinter

by Krishna Maurya -
Number of replies: 2

I m trying to execute simple python GUI code in VPL using tkinter but getting error

Below is my code

import tkinter


window = tkinter.Tk()

# to rename the title of the window

window.title("GUI")

# pack is used to show the object in the window

label = tkinter.Label(window, text = "Welcome to DataCamp's Tutorial on Tkinter!").pack()

window.mainloop()


What i'm missing. Thanks in advance

Attachment screenshot-learn.launchpadlearning.ca-2020.09.06-11_53_05.png
Average of ratings: -
In reply to Krishna Maurya

Re: no module named tkinter

by Juan Carlos Rodríguez-del-Pino -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Krishna Maurya,
I have typed your code and you can see the picture.
I think that there are two problems:
- The system does not autodetect correctly the need for a GUI environment when you use tkinter in Python. This was a known fail of previous VPL versions. Please, update VPL to the last version.
- It seems that the Tkinter package is not installed on your execution server. Run as root "apt-get install python3-tk" or the proper command in your server to install the needed package. Restart the server.

Best regards,
Juan Carlos.

Attachment Screenshot_2020-09-10 Pruebas tkinter Edit.png