Question : Linux / Python 2.5 / Tkinter  Will not import Tkinter

I am having trouble Making Python Tcl/Tk work on Linux.  I have mandrake linux 10.0 installed on my machine..  and I also have a Python Program that Import Tkinter .  Anyway when I try I get this message

Traceback (most recent call last):
  File "AllTk.py", line 1, in
    from Tkinter import *
  File "/usr/local/lib/python2.5/lib-tk/Tkinter.py", line 38, in
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter

and here is the import statement I am using

from Tkinter import *

/usr/local/lib/python2.5/lib-tk/Tkinter.py does exist.  when I run python Tkinter.py I get the same error.

I am definately running the 2.5 binary  already checked that.  So I'm not sure what is going on.  it seems
obvious that Python 2.5 comes preloaded with Tkinter.  So why doesnt it work?

Any help would be appreciated.  Thanks
scog

Answer : Linux / Python 2.5 / Tkinter  Will not import Tkinter

You would think TKinter is standard, but it is not on many Distros.  I don't run Mandrake.  But a lot of distro's do not include TKinter with their basic python packages.  I would check for additional packages probably looking more for packages.

For development I always build my python environment separate from the one included with the distro.  there are multiple reasons.  The one that might help here is not fighting through package dependencies when building from source is pretty easy and straightforward.

If TK is not installing properly that will definitely be an issue.

On a separate note - have you looked at wxPython?  It's another x-platform GUI toolkit.  I stopped using Tkinter about  2 years ago as it is quite primitive.  wxPython has it's faults - but it is more robust and is quite active.  I tend to look back at the time I spent learning Tkinter(mostly forgotten by now) as wasted time.  If you go this route - definitely build your own wxPython - the build instructions are complete enough, and I've yet to see the distro that provides any reasonably modern version of wxPython in it's packages.

I am trying to recall, but I think the packages to hookup python to Tkinter tend to be additional packages for python (not tk or tcl)  

I know it's not a full answer - but maybe it'll help you get moving.
Random Solutions  
 
programming4us programming4us