Solved

Linux / Python 2.5 / Tkinter  Will not import Tkinter

Posted on 2007-04-10
3
832 Views
Last Modified: 2013-12-15
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 <module>
    from Tkinter import *
  File "/usr/local/lib/python2.5/lib-tk/Tkinter.py", line 38, in <module>
    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
0
Comment
Question by:scogger1974
  • 2
3 Comments
 
LVL 1

Author Comment

by:scogger1974
ID: 18885312
It seems obvoius that  

/usr/local/lib/python2.5/lib-dynload/_tkinter.so   does not exist.  But how do i get it there... I've tried installing Tcl and Tk 8.4  Tcl installs fine... Tk has errors....

Thanks
0
 
LVL 1

Accepted Solution

by:
akameswaran earned 500 total points
ID: 18942123
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.
0
 
LVL 1

Author Comment

by:scogger1974
ID: 18958083
once I got on a ssytem that had yum.  I installed all tkinter packages available and it seemed to do the trick.   thanks for the comment.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now