473,714 Members | 2,240 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 4053
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
6733
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
5087
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
3211
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
3314
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
2156
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
2922
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
2957
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
8808
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
9316
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
9177
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
9021
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...
1
6637
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...
0
5951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3159
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2113
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.