I have installed Tcl and Tk, and I am running into the oh-so-familiar "No module named _tkinter" error.
My 'python' Bash command runs Python version 2.4.2, but Synaptic says I have 2.6.6 installed. I even tried installing 3.0, but that also failed.
I have configured and built the Tcl/Tk tarballs myself, and tried using the synaptic packages.
Both "wish" and "tclsh" commands work, so I know that the modules are installed, but I can't for the life of me get Python to recognize them. Moreover, I can't for the life of my figure out which version of Python I should be using and how to get my Bash command to use that one.
I don't see any options for 2.4.2 removal, and if I remove 2.6.6, it removes what seems to be most of my other packages (exaggeration, I know).
I really don't know where to go from here, so any guidance would be greatly appreciated.
I had to reinstall the python-tk package, and 2.6 is able to import it. Now I just need to figure out how to remove 2.4 for the sake of not screwing something up later on.
Here are a few commands which could help you diagnose your problem.
First, try to run the
python command with the version number appended. Since
Synaptic says you have 2.6.6 installed you should be able to run
get that version:
(type 'python' and hit TAB to see possible completions) % python<tab> python python2.6 python3.1
If you still can't get TK to run, find where the
_tkinter.so module lives on
your system. It may be somewhere the 2.6.6 interpreter can't find it. Here's the location as installed by
python-tk package on Ubuntu Lucid:
% find /usr -name '_tkinter*' /usr/lib/python2.6/lib-dynload/_tkinter.so
Just an update for those who land on this page, regarding Python 3+ (like I have). To run
tkinter on a Debian-based Linux (Ubuntu),
python3 is needed, as well as
python3-tk (it's not in the library list):
sudo apt-get install python3 sudo apt-get install python3-tk
Also, the script needs to have this as the first line:
At least that is how I solved the problem.