0

I am trying to make a very first desktop application using tkinter in pycharm like this.

from tkinter import *

root = Tk()
mLabel = Label(root, text="This is Header")
mLabel.pack
mLabel.mainloop()

But I got an exception saying

ImportError: No module named '_tkinter', please install the python3-tk package

And I tried to install the python3-tk like this

sudo apt-get install python3-tk

And I was raised with the exceptions like below enter image description here

Please guide me through What I am missing

Ram Mandal
  • 1,899
  • 1
  • 20
  • 35

1 Answers1

0

Maybe in your case, just running apt-get update before apt-get install python3-tk may be enough.

I had this problem while running it inside a Dockerfile. I had in my Dockerfile:

RUN apt-get update -y
RUN apt-get install python3-tk -y

And it was failing with the same message as yours.
I realised that if I ran both lines outside of Docker, they worked fine, and that the apt-get update was using cache while running the docker-compose build.
When I run docker-compose build --no-cache, it worked.

SherylHohman
  • 16,580
  • 17
  • 88
  • 94