Tom Boy
Tom Boy

Reputation: 659

Unable to solve "ImportError: No module named '_tkinter'"

When I try to run my program I keep getting the ImportError: No module named '_tkinter' error. I tried two things which I found could solve this problem:

sudo apt-get install python3-tk

sudo apt-get install tk-dev

They both say that they are up to date but I still get the no module named '_tkinter'.

Edit:

The error points to this line from tkinter import *

This is how I run the program that produces the error:

python3 myprog.py

Upvotes: 2

Views: 953

Answers (1)

user4171906
user4171906

Reputation:

Run this code and see what it says

import sys
if sys.version_info[0] < 3:
    import Tkinter as tk     ## Python 2.x
    print("Python 2.X")
else:
    import tkinter as tk     ## Python 3.x
    print("Python 3.X")
print "version", tk.TclVersion

Upvotes: 1

Related Questions