Solved

Linux / Python 2.5 / Tkinter  Will not import Tkinter

Posted on 2007-04-10
3
823 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

10 Experts available now in Live!

Get 1:1 Help Now