I am new to Ubuntu and Linux in general.

I created a dual boot OS on my laptop (Windows 10 and Ubuntu).

  • Typing: sudo apt-get install python3-tk (or even python-tk) didn't work.
  • Trying to install the python3-dev or python-devel (no luck).
  • Downloading Tcl and Tk to manually install.

In Windows 10 Bash Subsystem the Tk and Tcl are already included, so I thought Ubuntu already had it. But, I want to use my Ubuntu desktop to develop Python GUI apps.

So, how can I install the Tcl/Tk to be use in Python 3.5 for GUI development?

I loaded Python 3.5.2 fine but need the GUI modules enabled.

The code to test that Tk is working is:

  1. Type python3
  2. Type:

    import tkinter   
  3. Result: a GUI pop-up displaying This is a Tcl/Tk version..

  • 3
    " I loaded Python 3.5.2" - how exactly? if you are running a manually installed python then installing system python packages with apt-get is unlikely to help – steeldriver Aug 23 '16 at 17:07
  • 1
    I saw that your answer to your own question is to compile Tcl/Tk from source but I don't think that is needed unless you manually installed Python, i.e., without using the Apt package manager. Can you clarify if you had installed Python manually? Installing python3-tk and then running the Python code you provided works on my system Python 3. – edwinksl Aug 28 '17 at 17:15

sudo apt-get install python3-tk Installs tkinter for Python3.x.x


https://stackoverflow.com/questions/6084416/tkinter-module-not-found-on-ubuntu https://pythonprogramming.net/python-3-tkinter-basics-tutorial/

  • 5
    Note -- for python3.6 in which python3.5 was my default, I had to use ...install python3.6-tk.... – SteveJ Dec 7 '17 at 16:50
  • +1. I would add for those reading this that tkinter does not seem to have a PyPI package so that using the Ubuntu package manager as suggested in this answer is the likely the next best option. – dpritch Jul 29 '18 at 23:04
  • 1
    @dpritch There is a package available in the Universe repository called[ pypibrowser](packages.ubuntu.com/… which supplies the functionality I believe you are looking for. Cheers! – Elder Geek Aug 2 '18 at 18:49

A note -- for a python 3.6 virtual environment with a system python 3.5 , I had to install;

sudo apt-get install python3.6-tk

My default python in ubuntu was 3.5, so when using a venv for 3.6, I would get an import error. Drove me crazy for a while.

[Edit: In response to Elders very reasonable request]

The repository for python3.6-tk (in my case) was the same for that of python 3.6

sudo add-apt-repository ppa:deadsnakes/ppa

The aforementioned repository has the python3.6-tk package available for both xenial and trusty as well as the very recently released Python 3.7.0 beta 2 release.

However, this answer will be dated once 3.6+ is mainstream on Ubuntu as I suspect it will be in the main repository.

  • 1
    Interesting. You might go so far as to explain which PPA you installed it from as as far as I can see python3.6-tk doesn't exist in the repositories at this moment. – Elder Geek Feb 19 '18 at 13:55
  • 1
    I made a further edit in an attempt to make it more current. – Elder Geek Mar 1 '18 at 18:55
  • 2
    FINALLY! This is the worked for me when sudo apt-get install python3-tk did not. Thanks – Peter Jun 13 '18 at 12:39
  • For python 3.7 I had to use sudo apt-get install python3.7-tk to make it work – ilias Aug 21 at 5:49

This might be interesting when installing from source (which most python users won't):

After installing tcl and tk.

Go back to your version of Python, do make. And, if multiple version of python exist, do a make altinstall.

  1. Open Python3.5
  2. type:

    import tkinter
  3. results OK - pop GUI opened and working as expected.

  • 2
    -1 This will not be relevant to most people as most will install via package manager rather than from source. – RockJake28 Jun 19 '17 at 10:36
  • added introduction, so it won't confuse and still might help someone – mit Nov 20 '18 at 8:23

In my case, I was getting the same error as "ImportError: No module named '_tkinter'" for python3.5 in-spite of doing the following things: - Installing python3-tk and tkinter-dev - Tkinter directory being available in /usr/lib/python3.5.

The observed error was from the following file:

File "/usr/local/lib/python3.5/tkinter/init.py", line 35, in import _tkinter # If this fails your Python may not be configured for Tk

However, when I simply ran the python from /usr/bin like /usr/bin/python3.5 from terminal, it worked for me!

In short, just ensure the python version being run from terminal has the tkinter installed and configured :)

I have Ubuntu16.04 installed on my system which comes with default python2.7 and python3.5


Installing just library files may not work since you want to use library itself not develop it.

This worked for me:

$ sudo apt install tk8.6-dev
  • while this may answer the question, perhaps you could expand it to explain what the above command does and why it could fix the issue? – Joshua Besneatte Jul 18 at 18:47
  • ismailarilik What @JoshuaBesneatte is trying to say is: don't only give the requester the commands, but explain what the commands do and why he/she should apply it. As it stands, your answer is likely to be deleted because of lack of quality... :-( – Fabby Jul 18 at 22:09

protected by Community Jul 23 at 20:52

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.