Building Python with Tkinter support
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 :study: 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?
Thank you |
have you tried "import Tkinter" with an uppercase T as first letter.
|
That also does not work, I get the same error message with "No module named _tkinter"
|
Sounds like you didn't install Tkinter properly then. Care to describe how you installed it?
|
I did it all from RPMs, and I made sure to install everything it required. Should I try to remove those and do it from source?
|
What RPMs did you install? Where did you get them? What versions of each did you install? Are you sure they are successfully installed? etc.
|
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
|
There might be some sort of python-tk or python-tkinter package you have to install, as I'm not sure what is in the tkinter rpm. Also, does your python version match up with the tkinter version?
|
My python is the newest one, I just got it and compiled it off of python.org. Version 2.3.3. My tkinter is 2.2.3, is that the problem then?
|
If you got it and compiled it off of python.org, I think it includes Tkinter unless you tell it not to compile that .... but I haven't compiled Python in a looong time so I can't be sure.
To answer your question, though, yes if your version of Tkinter and your version of Python don't match up, then they won't work together (in all likelihood). |
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.
|
The docs only say to edit /modules/setup for tkinter support, but all that it says there is that tkinter is automatically enabled, and to 'edit the line below' if I want to change the directory. :s
Makes no sense at all, but it couldnt hurt to try reinstalling. I have Qt installed and working, is that a decent substitute? |
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?
|
The TCL Tickler
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:
Code:
ldd /usr/lib/python2.5/lib-dynload/_tkinter.so Code:
python
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.
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. :confused: x100 OK then, let Googlebot chase this: tftp://atr2.ath.cx/tcl-tk-tix-tickler.shar 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). |
All times are GMT -5. The time now is 07:46 PM. |