1

I am using some python3.7 code that is running tensorflow under the hood. When I run it I get the following error:

import tkinter as Tk
ModuleNotFoundError: No module named 'tkinter'

I did some googling and found that I need to install python3-tk so I ran the following command:

sudo apt-get install python3-tk

and get the following output confirming that it is installed:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-tk is already the newest version (3.5.1-1).
0 upgraded, 0 newly installed, 0 to remove and 108 not upgraded.

Yet when I get into my python3.7 interpreter and test it with the following commands

$python3.7
>> import tkinter

I get the following output saying it is not installed:

$ python3.7
Python 3.7.3 (default, Mar 26 2019, 01:59:45) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tkinter'

How do I go about getting tkinter to run on python3.7 when apt already thinks it is installed? As a side not I am on Ubuntu 16.

Tyler Hilbert
  • 2,107
  • 7
  • 35
  • 55

1 Answers1

4

@davedwards solved this problem with the following command:

sudo apt-get install python3.7-tk
Pablo EM
  • 6,190
  • 3
  • 29
  • 37
Tyler Hilbert
  • 2,107
  • 7
  • 35
  • 55