I have an old computer that doesn't have internet access. It does have Python 2.6 which supposedly has Tkinter. The problem is, it returns an error that Tkinter module is not installed. I searched the net, and saw that I may have to manually install tcl/tk. Done. I tried

import _tkinter

Still no module. How can I use Tkinter on a machine with no net access? On my laptop, I had to install Tkinter from the repositories, but this isn't an option for the old Celeron. So is it installed or not?

Try "import Tkinter", note the capital "T". You have to have a match between the tkinter version and the TCL/Tk version. TCL & Tk should be subdirectories in /usr/lib and would be version 8.5 to go with Python 2.6x. Tkinter will be in /usr/lib/python/lib-tk. Also, python has to be compiled with Tkinter support. How did you build python and where did the code come from. Your distro should have prebuilt binaries for TCK, Tk, and Python with Tkinter support.

To answer your last question first, Python is included in the Ubuntu 9.04 live-cd that I used to install Ubuntu on my old machine. I found the tcl/tk libs in /usr/lib, they're both 8.5. Where in the /usr/lib/python2.6/lib-tk will I find the Version number to match? My gui program tries to use import Tkinter and returns an error about no module, that's when I found a wiki page that said to try import _tkinter as a test. It said if that failed, I should re-build python. Not real sure how to do that.

First see where /usr/bin/python points to as that is what is being called by the shebang in the first line of the program. It may be pointing to another version of Python that does not have Tkinter installed. Next, if you have a /usr/lib/site-packages/lib-tk, run one of the programs like "ScrolledText.py". Your versions appear to be OK. Ubuntu would package the correct versions together, so it's a good bet that /usr/bin/python, or /usr/local/bin/python points somewhere else. Try this

#!/usr/bin/python2.6

import Tkinter

and see if it runs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.