Solved

Linux / Python 2.5 / Tkinter  Will not import Tkinter

Posted on 2007-04-10
3
843 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to use pyenv 4 38
VMware Workstation 12 Player 16 75
android secure ftp 3 38
windows 7 starter missing password 21 78
A set of related code is known to be a Module, it helps us to organize our code logically which is much easier for us to understand and use it. Module is an object with arbitrarily named attributes which can be used in binding and referencing. …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…

809 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