ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I've got python installed on my RH9 machine, and I installed Tkinter and all of it's dependancies. When I run 'import tkinter' from the python shell, it says that the module cannot be found. I have read many places that this means I have to configure python to use tkinter, but I cannot find anything that tells me how to do it. Have any of you gotten this working? If so, how did you do it?
I did a rpm search at rpm.pbone.net for Tkinter, downloaded and installed tcl-8.3.1-53.i386.rpm and tk-8.3.3-4cl.i386.rpm. Also says I have tkinter-2.2.3-5.i386.rpm installed. I just checked the package section of my logs, and thats what I found
Well.. I installed it, and it wasnt there. That was the original reason I started this thread, because I figured I hadnt specified to install it. What I am going to try to do is just remove all copies of python and tkinter and start over again. Should I install Python first, and then tkinter, or vice versa?
Well, like I said, if you are compiling Python from source from python.org, I think that it comes with Tkinter. You might have to specify some special build instructions to build it, so I'd check the docs that come with it. I've not compiled Python in a long time and I never worried about having Tkinter support when I did, so ... I'm not anywhere close to an expert on building Python or Tkinter.
I removed tkinter, and reinstalled it using apt-get, then I rebuit python. same error though. I dont suppose there is a way to manually copy the Tkinter files to the directory they need to be in, is there?
Since we're snowed in here in the North east US, I took the time to get to the bottom of this. All this time I thought I had a working _tkinter, until I tried to run fetchmailconf (ironically, I can hand-write its config files..., still, a bad milter-regex rule ate all 35 of my emails anyway so it didn't do much good, beyond what I figured out here.) Out of curiousity, I wonder just how many people have had this problem. It seems Python installs Tkinter.py anyway, even if Tk support as a whole doesn't work. Searching for "_tkinter " turns up a slew of posts, none that I saw with a solid answer. The file that matters, assuming you compiled python modules dynamically, is _tkinter.so:
As you can see, it's quite the shlib beast. If you have working tkinter.so support, you should see this instead of an error message:
Python 2.5 (r25:51908, Feb 14 2007, 15:43:17)
[GCC 4.1.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _tkinter
Most of the trouble seems to be not in Python itself, but in getting TCL/Tk/Tix to install, which is no small feat considering what one must do. The versions I used to preform this miracle are as follows, all off their (Sourceforge) project pages, and Python of its site page:
They are all current as of this writing. Likely you already have some version of these. My personal recommendation if you're going to do a full rebuild, is whack all of it with exception of the shared libs. Those move and tuck away someplace safe, in case something un-rebuildable is linking against them. If it is, simply copy them back and re-run ldconfig to update the ld.so.cache.
Clean up the old version of those programs, including manpages, and docs.
Unpack Tcl, Tk, and its Thread add-on. Each of these must be built twice: once non-shared and once shared. See the build scripts.
TCL and Tk in the past did not install their headers properly. Apps in the past wanted the "private headers", which the install skipped. We use /usr/include/tcl for all these due to namespace clashes. See the build scripts for how to force their install. WIth Tix, you must manually find and copy them.
Apply the two patches to fix up b0rked headers: tcl-8.5a5-hold-the-MODULE_SCOPE-kthx.patch.gz tix-8.4.0-ERR_IN_PROGRESS-is-nomore.patch.gz. I'm no C programmer, these are probably not the best ways to fix these, but it works.
Clean up the TCL/Tk install. Both install tclConfig.sh/tkConfig.sh scripts in /usr/lib. These insist on referencing the build directory, which is about to rm -rf'ed. Remove all references to those paths by setting empty variables. Add -I/usr/include/tcl to the CFLAGS so the headers can be found later. Unversion the libraries: I find it highly annoying to have to link against -ltcl8.5a5. Easier is -ltcl. See the build scripts again for examples for both the .so libs and .a libs.
Build Tix. See the tix build script for all the stuff that needs to be done. There is alot of minor fixes. Don't forget to lower-case the paths and lib names in unix tradition. Headers need to found in the source tarball and copied to /usr/include/tcl.
Tixwish is MIA. Maybe it fell out of bag on the way home? Don't forget to un-version tclsh and wish. I hate typing "tclsh8.5.a.5.blah.blah.etc.and.so.on" instead of "tclsh"! Probably you will, too.
Re-install python to link against the shiney-new TCL/Tk/Tix stuff. I've included the Modules/Setup file that shows what to select to get a working tkinter. Make sure you updated the shared libs ld.so.cache before python building.
You can use Idle now as well. Marvel at the beautiful fetchmailconf program.
The magic shar: I've tried to upload this shar no less than 20 times, using three different ways, uuencoded, base64 encoded, and plain. 100% of the time it snaps my dial-up connection when I try to send it. Bonus points for figuring out why.
OK then, let Googlebot chase this:
Try again in awhile if the link is down, my ISP likes to disconnect me randomly.
You can probably use "sh" for the scripts if you don't have "zsh", but I know everyone has zsh because it's the best shell around
The scripts are meant to execute in the top level of the archive they are building. Actually, it's best you use the scripts as guide for what to type, and type in each command yourself and wait for it to run, rather than letting them fly on auto-pilot. They were made quickly as I worked thru this, so they are far from fault-tolerant or forgiving for multiple system layouts.
After this, when you want to build with tcl/tk/tix just do something like: gcc -o prog -I/usr/include/tcl tclprog.c -ltcl (or -ltk or -ltix, whichever the case may be).