views:

182

answers:

1

Hi,

I have an existing Python 2.4 and it is working properly with tkinter as I tested it using

python

import _tkinter

import Tkinter Tkinter._test()

Now, I have installed python 2.5.2 but when I try the same tests (with the newer version), it returns (but the same tests are working for the previous version)

ImportError: No module named _tkinter

I know that tcl8.5 and tk8.5 are installed on my machine as the following commands return there locations

whereis tcl tcl: /usr/lib/tcl8.4 /usr/local/lib/tcl8.5 /usr/local/lib/tcl8.4 /usr/share/tcl8.4

whereis tk tk: /usr/lib/tk8.4 /usr/local/lib/tk8.5 /usr/share/tk8.4

Any ideas how do I make my newer python version work with tkinter?

+1  A: 

The files you found are for linking directly to tcl/tk. Python depends on another library as well: _tkinter.so. It should be in /usr/lib/python2.5/lib-dynload/_tkinter.so.
How did you install python2.5? If you are using Debian or Ubuntu you need to install the python-tk package to get Tkinter support.

If the _tkinter.so file is there, your environment could be causing problems. If

python -E -c "import Tkinter;Tkinter._test()"

suceeds, but

python -c "import Tkinter;Tkinter._test()"

fails, then the problem is with how your environment is set up. Check the value of PYTHONPATH is set correctly.

sjf