473,691 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python/Tk not working in Linux

I am using Fedora Core 3 Linux and I have a problem with Tk in Python.
Whenever I try to run a tk script, I get the error...

---------------
Traceback (most recent call last):
File "Tk.py", line 1, in ?
from Tkinter import *
File "/usr/local/lib/python2.4/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
---------------

I get this error with even the most basic Python/Tk scripts like

---------------
from Tkinter import *

class Application(Fra me):
def createWidgets(s elf):
self.lab = Label(text="Hel lo World")
self.lab.pack()

def __init__(self, master=None):
Frame.__init__( self, master)
self.pack()
self.createWidg ets()

app = Application()
app.mainloop()
------------------

However python script that does not used Tk works fine.

I have tried to solve this problem by reinstalling Python from source -
but still no luck. Ruby also fails this way in my system - ruby works -
but not Ruby with Tk. However Perl/Tk and Tcl/Tk works fine.

Any suggestions?

--
Binny V A
http://www.bin-co.com/perl/perl_tk_tutorial/ - Perl/Tk
http://www.bin-co.com/tcl/tutorial/ - Tcl/Tk

Aug 12 '06 #1
4 4052
In <11************ **********@m79g 2000cwm.googleg roups.com>, BinnyVA wrote:
I am using Fedora Core 3 Linux and I have a problem with Tk in Python.
Whenever I try to run a tk script, I get the error...

---------------
Traceback (most recent call last):
File "Tk.py", line 1, in ?
from Tkinter import *
File "/usr/local/lib/python2.4/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
---------------
The `_tkinter` module is the binary "bridge" to the Tk system. If it's
not found it's most likely that the relevant header files of tcl/tk where
not installed before compiling Python or there was a problem while
compiling this extension.

This seems to be your self compiled Python. Are you sure you got the same
error when using the version from your distribution? I would suspect you
get an `ImportError` on `Tkinter` there. Some distributions move the
`Tkinter` stuff into an own package. Search for a package called
`python-tk` or `python-tkinter` or similar.

Ciao,
Marc 'BlackJack' Rintsch
Aug 12 '06 #2
In article <pa************ *************** *@gmx.net>,
Marc 'BlackJack' Rintsch <bj****@gmx.net wrote:
>In <11************ **********@m79g 2000cwm.googleg roups.com>, BinnyVA wrote:
>I am using Fedora Core 3 Linux and I have a problem with Tk in Python.
Whenever I try to run a tk script, I get the error...

---------------
Traceback (most recent call last):
File "Tk.py", line 1, in ?
from Tkinter import *
File "/usr/local/lib/python2.4/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
---------------

The `_tkinter` module is the binary "bridge" to the Tk system. If it's
not found it's most likely that the relevant header files of tcl/tk where
not installed before compiling Python or there was a problem while
compiling this extension.

This seems to be your self compiled Python. Are you sure you got the same
error when using the version from your distribution? I would suspect you
get an `ImportError` on `Tkinter` there. Some distributions move the
`Tkinter` stuff into an own package. Search for a package called
`python-tk` or `python-tkinter` or similar.
Aug 12 '06 #3
Some distributions move the
`Tkinter` stuff into an own package. Search for a package called
`python-tk` or `python-tkinter` or similar.
I could use a 'python-tk' package - but the problem is the latest
version of python may not be available.

I am going to download Tcl/Tk and install it. Then I would try to
install Python once again. If that works, great. If not I will install
a full 'python-tk' package. Maybe
'ActivePython'(http://www.activestate.com/Products/...d=ActivePython)
like Cameron Laird have suggested.

--
Binny V A
http://www.bin-co.com/ - Bin-Co

Aug 14 '06 #4
In <11************ **********@m79g 2000cwm.googleg roups.com>, BinnyVA wrote:
>Some distributions move the `Tkinter` stuff into an own package.
Search for a package called `python-tk` or `python-tkinter` or similar.

I could use a 'python-tk' package - but the problem is the latest
version of python may not be available.
That's always the problem with packaged software. But you gain fast and
easy installation via the package system.
I am going to download Tcl/Tk and install it. Then I would try to
install Python once again.
Just install the necessary development packages for your installed Tcl/Tk
and compile the Python sources. Unless you really want to compile
everything yourself.

Ciao,
Marc 'BlackJack' Rintsch
Aug 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
6729
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the language's 30+ year evolution. What to you think python largest compromises are? The three that come to my mind are significant whitespace, dynamic typing, and that it is interpreted - not compiled. These three put python under fire and cause...
34
5083
by: Maboroshi | last post by:
Hello My question has to do with python and linux - I was interested in finding out what it would take to reimplement the Linux Kernel in python basically just taking the source code from linux and rewriting it in python Would this idea make sense to do - if so what would be the benefits of doing this and in what way would this not be a good idea Cheers
7
3209
by: Edward Diener | last post by:
I can install Python 2.4 on the Fedora 3 Linux system, but after I do a number of Linux utilities and commands, like yum, stop working because they were dependent on the Python 2.3 installation. What happens is that Python 2.4 replaces the /usr/bin/python module with the Python 2.4 version. If I replace /usr/bin/python with the Python 2.3 version executable, which is still on my system, that all the aforesaid modules depend on, they start...
10
3306
by: callmebill | last post by:
I'm getting my feet wet with making Python talk to MySQL via ODBC. I started on Windows, and it went smoothly enough due to the ODBC stuff that apparently is native to Python at least on windows (I've been following ch. 13 of Mark Hammond's py on win32 book). But now I'm trying to do equivalent stuff on linux (Fedora Core 3) with python 2.3.5 and mysql. I'd like to stick with packages that are native to python, rather than relying on...
25
2149
by: redefined.horizons | last post by:
I've traditionally been a Java developer, although I play around with LISP. I recently migrated to Linux and I was exploring Mono as an option for development on Linux. However, I've had some problems with the maturity and support when working with Mono. So I was considering Python as an alternative development language. Is Python actively developed and supported on Linux? Would it be a viable option for cross-platform application...
1
2920
by: Vyacheslav Sotnikov | last post by:
Hello python-list, is anybody has any success in taking this components live together? I need to access remote Oracle 9i from freebsd 6.2 machine using python 2.4.4. Thanks in advance for answer.
15
2952
by: John Nagle | last post by:
I've been installing Python and its supporting packages on a dedicated server with Fedora Core 6 for about a day now. This is a standard dedicated rackmount server in a colocation facility, controlled via Plesk control panel, and turned over to me with Fedora Core 6 in an empty state. This is the standard way you get a server in a colo today. Bringing Python up in this completely clean environment is a huge hassle, and it doesn't...
0
8599
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8531
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9079
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8951
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8794
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6457
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2227
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1952
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.