Python 2.4 and Tkinter

J

Jeffrey Barish

Since upgrading to python 2.4 yesterday, I am no longer able to use
Tkinter. From http://www.python.org/moin/TkInter I learned that I need
to edit Modules/Setup to include Tkinter during the make. However, it
isn't clear to me what modifications to make. I am supposed to specify
directories in which needed files can be found. I found the Tcl/Tk
libraries in /usr/local/lib/python2.4/lib-tk, but I can't find the
Tcl/Tk headers. The default value for the headers (/usr/local/include)
doesn't work. I searched my system for tcl.h but couldn't find it.
Does anyone know how to make Tkinter work under Python 2.4?

I also don't understand why I have to go to all this trouble. Tkinter
is supposed to be included with Python, so shouldn't it be available
without any special effort?
 
J

Jean Brouwers

FWIW, we just installed Python 2.4 (on RH Linx 8), rebuilt it from
scratch and everything is fine. Tkinter is there, _tkinter as well and
idle comes up as expected.

/Jean Brouwers
 
J

Jeffrey Barish

Jean said:
FWIW, we just installed Python 2.4 (on RH Linx 8), rebuilt it from
scratch and everything is fine. Tkinter is there, _tkinter as well
and idle comes up as expected.

/Jean Brouwers

Here's what I get when I import Tkinter at a python prompt:

jeffbarish@duo:~$ python
Python 2.4 (#1, Nov 30 2004, 08:58:13)
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
File "<stdin>", line 1, in ?
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 tried make clean and make. Same result. Ah, now I see that the
output from make includes:

INFO: Can't locate Tcl/Tk libs and/or headers

Aren't the libs and headers included in Python-2.4.tgz?
 
J

Jean Brouwers

Here is how we understand this (which may be incomplete and/or
incorrect).

The _tkinter module is a shared library _tkinter.o and that is built
from C source file _tkinter.c. That C file and a few other tk related
C files are included in the Python distribution.

But the Tcl/Tk libraries to build the _tkinter module are coming from
/usr/local/lib in our case. And those happens to be tcl83 and tk83 in
our case.

If the Tcl/Tk libraries (and include files) are missing, you will have
to get and install those. But they are not part of the Python
distribution, as far as we know.

/Jean Brouwers



Jeffrey Barish said:
Jean said:
FWIW, we just installed Python 2.4 (on RH Linx 8), rebuilt it from
scratch and everything is fine. Tkinter is there, _tkinter as well
and idle comes up as expected.

/Jean Brouwers

Here's what I get when I import Tkinter at a python prompt:

jeffbarish@duo:~$ python
Python 2.4 (#1, Nov 30 2004, 08:58:13)
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
File "<stdin>", line 1, in ?
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 tried make clean and make. Same result. Ah, now I see that the
output from make includes:

INFO: Can't locate Tcl/Tk libs and/or headers

Aren't the libs and headers included in Python-2.4.tgz?
 
E

Eric Brunel

Jeffrey Barish wrote:
[snip]
Here's what I get when I import Tkinter at a python prompt:

jeffbarish@duo:~$ python
Python 2.4 (#1, Nov 30 2004, 08:58:13)
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Traceback (most recent call last):
File "<stdin>", line 1, in ?
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 tried make clean and make. Same result. Ah, now I see that the
output from make includes:

INFO: Can't locate Tcl/Tk libs and/or headers

Aren't the libs and headers included in Python-2.4.tgz?

On Windows, the Python distribution does include Tkinter and tcl/tk. It's
different on Unices (including Linux): since tcl/tk is very often installed by
default, it is not included in the Python distribution.

Have you looked for libraries / header files in /usr/lib and /usr/include? This
is usually where they go when you install them with Linux. Since you mentionned
you upgraded to Python 2.4, I assume you had a working installation of a
previous Python version. So the tcl/tk libraries and header files must be there
somewhere. Did you look at your Modules/Setup for the older Python? If Tkinter
was working with this version, the setup for the _tkinter module should use the
correct paths.

HTH
 
J

Jeffrey Barish

Jean said:
Here is how we understand this (which may be incomplete and/or
incorrect).

The _tkinter module is a shared library _tkinter.o and that is built
from C source file _tkinter.c. That C file and a few other tk related
C files are included in the Python distribution.

But the Tcl/Tk libraries to build the _tkinter module are coming from
/usr/local/lib in our case. And those happens to be tcl83 and tk83 in
our case.

If the Tcl/Tk libraries (and include files) are missing, you will have
to get and install those. But they are not part of the Python
distribution, as far as we know.

/Jean Brouwers



Jeffrey Barish said:
Jean said:
FWIW, we just installed Python 2.4 (on RH Linx 8), rebuilt it from
scratch and everything is fine. Tkinter is there, _tkinter as well
and idle comes up as expected.

/Jean Brouwers



http://www.python.org/moin/TkInter

Here's what I get when I import Tkinter at a python prompt:

jeffbarish@duo:~$ python
Python 2.4 (#1, Nov 30 2004, 08:58:13)
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in ?
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 tried make clean and make. Same result. Ah, now I see that the
output from make includes:

INFO: Can't locate Tcl/Tk libs and/or headers

Aren't the libs and headers included in Python-2.4.tgz?

OK, I downloaded tcl8.4.8 and tk8.4.8. They are now installed. Back to
python2.4 make. It now bombs at:

gcc -pthread -shared build/temp.linux-i686-2.4/_tkinter.o
build/temp.linux-i686-2.4/tkappinit.o -L/usr/X11R6/lib64
-L/usr/X11R6/lib -L/usr/local/lib -ltk8.4 -ltcl8.4 -lX11 -o
build/lib.linux-i686-2.4/_tkinter.so
*** WARNING: renaming "_tkinter" since importing it failed: libtk8.4.so:
cannot open shared object file: No such file or directory
running build_scripts

Here's what I don't get:

root@duo:/tmp/Python-2.4# ls -l /usr/local/lib/libtk8.4.so
-rwxr-xr-x 1 root staff 893866 2004-12-02
15:28 /usr/local/lib/libtk8.4.so

The library is there but gcc claims that it isn't. Any suggestions?
 
J

Jean Brouwers

It is hard to tell what is wrong, exactly. Two suggestions:

If this is a 32-bit build, why is there a "-L/usr/X11R6/lib64" and
*before* the regular "-L/usr/X11R6/lib"? Try to rerun just that line
"gcc -pthread .... _tkinter.so" but without the "-L/usr/X11R6/lib64"
option.

If that still fails, try a fresh reconfigure and rebuild from scratch,
now that the Tcl/Tk libs are there. Start with "./configure ...." per
the instructions in the README file, run "make clean" etc..

/Jean Brouwers



Jeffrey Barish said:
Jean said:
Here is how we understand this (which may be incomplete and/or
incorrect).

The _tkinter module is a shared library _tkinter.o and that is built
from C source file _tkinter.c. That C file and a few other tk related
C files are included in the Python distribution.

But the Tcl/Tk libraries to build the _tkinter module are coming from
/usr/local/lib in our case. And those happens to be tcl83 and tk83 in
our case.

If the Tcl/Tk libraries (and include files) are missing, you will have
to get and install those. But they are not part of the Python
distribution, as far as we know.

/Jean Brouwers



Jeffrey Barish said:
Jean Brouwers wrote:


FWIW, we just installed Python 2.4 (on RH Linx 8), rebuilt it from
scratch and everything is fine. Tkinter is there, _tkinter as well
and idle comes up as expected.

/Jean Brouwers



http://www.python.org/moin/TkInter

Here's what I get when I import Tkinter at a python prompt:

jeffbarish@duo:~$ python
Python 2.4 (#1, Nov 30 2004, 08:58:13)
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in ?
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 tried make clean and make. Same result. Ah, now I see that the
output from make includes:

INFO: Can't locate Tcl/Tk libs and/or headers

Aren't the libs and headers included in Python-2.4.tgz?

OK, I downloaded tcl8.4.8 and tk8.4.8. They are now installed. Back to
python2.4 make. It now bombs at:

gcc -pthread -shared build/temp.linux-i686-2.4/_tkinter.o
build/temp.linux-i686-2.4/tkappinit.o -L/usr/X11R6/lib64
-L/usr/X11R6/lib -L/usr/local/lib -ltk8.4 -ltcl8.4 -lX11 -o
build/lib.linux-i686-2.4/_tkinter.so
*** WARNING: renaming "_tkinter" since importing it failed: libtk8.4.so:
cannot open shared object file: No such file or directory
running build_scripts

Here's what I don't get:

root@duo:/tmp/Python-2.4# ls -l /usr/local/lib/libtk8.4.so
-rwxr-xr-x 1 root staff 893866 2004-12-02
15:28 /usr/local/lib/libtk8.4.so

The library is there but gcc claims that it isn't. Any suggestions?
 
J

Jeffrey Barish

Jean said:
It is hard to tell what is wrong, exactly. Two suggestions:

If this is a 32-bit build, why is there a "-L/usr/X11R6/lib64" and
*before* the regular "-L/usr/X11R6/lib"? Try to rerun just that line
"gcc -pthread .... _tkinter.so" but without the "-L/usr/X11R6/lib64"
option.

If that still fails, try a fresh reconfigure and rebuild from scratch,
now that the Tcl/Tk libs are there. Start with "./configure ...." per
the instructions in the README file, run "make clean" etc..

/Jean Brouwers



Jeffrey Barish said:
Jean said:
Here is how we understand this (which may be incomplete and/or
incorrect).

The _tkinter module is a shared library _tkinter.o and that is
built
from C source file _tkinter.c. That C file and a few other tk
related C files are included in the Python distribution.

But the Tcl/Tk libraries to build the _tkinter module are coming
from
/usr/local/lib in our case. And those happens to be tcl83 and tk83
in our case.

If the Tcl/Tk libraries (and include files) are missing, you will
have
to get and install those. But they are not part of the Python
distribution, as far as we know.

/Jean Brouwers



Jean Brouwers wrote:


FWIW, we just installed Python 2.4 (on RH Linx 8), rebuilt it
from
scratch and everything is fine. Tkinter is there, _tkinter as
well and idle comes up as expected.

/Jean Brouwers



<[email protected]>, Jeffrey

http://www.python.org/moin/TkInter

Here's what I get when I import Tkinter at a python prompt:

jeffbarish@duo:~$ python
Python 2.4 (#1, Nov 30 2004, 08:58:13)
[GCC 3.2.3 20030316 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in ?
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 tried make clean and make. Same result. Ah, now I see that the
output from make includes:

INFO: Can't locate Tcl/Tk libs and/or headers

Aren't the libs and headers included in Python-2.4.tgz?

OK, I downloaded tcl8.4.8 and tk8.4.8. They are now installed. Back
to
python2.4 make. It now bombs at:

gcc -pthread -shared build/temp.linux-i686-2.4/_tkinter.o
build/temp.linux-i686-2.4/tkappinit.o -L/usr/X11R6/lib64
-L/usr/X11R6/lib -L/usr/local/lib -ltk8.4 -ltcl8.4 -lX11 -o
build/lib.linux-i686-2.4/_tkinter.so
*** WARNING: renaming "_tkinter" since importing it failed:
libtk8.4.so: cannot open shared object file: No such file or
directory running build_scripts

Here's what I don't get:

root@duo:/tmp/Python-2.4# ls -l /usr/local/lib/libtk8.4.so
-rwxr-xr-x 1 root staff 893866 2004-12-02
15:28 /usr/local/lib/libtk8.4.so

The library is there but gcc claims that it isn't. Any suggestions?

It turns out that the problem is in the step after the gcc. I have now
tracked it into setup.py. There is a call to imp.load_dynamic() that
fails. I haven't been able to figure out why yet, in large part
because I am not familiar with module imp (and imp.load_dynamic isn't
even documented).
 
E

Eric Brunel

Jeffrey Barish wrote:
[snip]
OK, I downloaded tcl8.4.8 and tk8.4.8. They are now installed. Back to
python2.4 make. It now bombs at:

gcc -pthread -shared build/temp.linux-i686-2.4/_tkinter.o
build/temp.linux-i686-2.4/tkappinit.o -L/usr/X11R6/lib64
-L/usr/X11R6/lib -L/usr/local/lib -ltk8.4 -ltcl8.4 -lX11 -o
build/lib.linux-i686-2.4/_tkinter.so
*** WARNING: renaming "_tkinter" since importing it failed: libtk8.4.so:
cannot open shared object file: No such file or directory
running build_scripts

Here's what I don't get:

root@duo:/tmp/Python-2.4# ls -l /usr/local/lib/libtk8.4.so
-rwxr-xr-x 1 root staff 893866 2004-12-02
15:28 /usr/local/lib/libtk8.4.so

The library is there but gcc claims that it isn't. Any suggestions?

Is /usr/local/lib in your LD_LIBRARY_PATH environment variable? It needs to be
in the compiler options for the compilation phase, but then you have to put it
in $LD_LIBRARY_PATH to be able to import the module.

HTH
 
J

Jeffrey Barish

Eric said:
Jeffrey Barish wrote:
[snip]
OK, I downloaded tcl8.4.8 and tk8.4.8. They are now installed. Back
to
python2.4 make. It now bombs at:

gcc -pthread -shared build/temp.linux-i686-2.4/_tkinter.o
build/temp.linux-i686-2.4/tkappinit.o -L/usr/X11R6/lib64
-L/usr/X11R6/lib -L/usr/local/lib -ltk8.4 -ltcl8.4 -lX11 -o
build/lib.linux-i686-2.4/_tkinter.so
*** WARNING: renaming "_tkinter" since importing it failed:
libtk8.4.so: cannot open shared object file: No such file or
directory running build_scripts

Here's what I don't get:

root@duo:/tmp/Python-2.4# ls -l /usr/local/lib/libtk8.4.so
-rwxr-xr-x 1 root staff 893866 2004-12-02
15:28 /usr/local/lib/libtk8.4.so

The library is there but gcc claims that it isn't. Any suggestions?

Is /usr/local/lib in your LD_LIBRARY_PATH environment variable? It
needs to be in the compiler options for the compilation phase, but
then you have to put it in $LD_LIBRARY_PATH to be able to import the
module.

HTH

That was the problem. Thanks for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top