tkinter import error on ubuntu 16.4 tkinter import error on ubuntu 16.4 tkinter tkinter

tkinter import error on ubuntu 16.4


At the bottom of your post you say:

Note that I ran the code in python 2.7 and it ran successfully.

When you import Tkinter from Python 2 you must say:

import Tkinter

When you import Tkinter from Python 3 you must say:

import tkinter

A snippet I use for Tkinter when I know that my script is going to be ran from multiple versions of Python is below:

import syspy_version = int(sys.version[0])# If the python version is lower than 3, use Python 2 importif py_version < 3:    import Tkinter# Otherwise use Python 3 import else:    import tkinter

IF THE ABOVE DID NOT FIX YOUR PROBLEM:

I see that in one of your error messages it says

python3-tk is already the newest version (3.5.1-1).

But the error message also says that your Python version is 3.6.

Try using: sudo apt-get install python3.6-tk