Fix “ImportError: No module named _tkinter” In Debian/Ubuntu and Derivatives

by
Share this Article: Facebook0Google+0Twitter13LinkedIn0Reddit0StumbleUpon1

Hey Guys,

As a Python beginner, I always like to share problems I encounter as I move along to day I got an import error on my Cruchbang box and want share with you. I guess you might also have had the same issue hence coming across this.

In this tutorial, we fix a simple import error below after running >>> import turtle

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

Here is the full view of how this error was caught.

import_turtle

python
 Python 3.4.1 (default, May 19 2014, 17:23:49)
 [GCC 4.9.0 20140507 (prerelease)] on linux
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import turtle
 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib/python3.4/turtle.py", line 107, in <module>
 import tkinter as TK
 File "/usr/lib/python3.4/tkinter/__init__.py", line 38, in <module>
 import _tkinter # If this fails your Python may not be configured for Tk
 ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
 >>>

The error message is very clear and all that needs to be installed is Tkinter

sudo apt-get install python-tk

Next time your import turtle from python shell it should pass.

 >>> import turtle
 >>>

import_turtle_fixed

Hope this helps!

For questions please refer to our Q/A forum at : http://ask.unixmen.com/

Share this Article: Facebook0Google+0Twitter13LinkedIn0Reddit0StumbleUpon1