By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,028 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,028 IT Pros & Developers. It's quick & easy.

_tkinter installation in python 2.5 on mandriva with a default 2.4

P: n/a
I'm running on Mandriva 2007 (2.6.17-5mdv) and thus have python2.4.3
installed by default,
I'm running code requiring yield(), so need python2.5 and have
installed this sucessfully, and linked appropriately to allow me to
start python2.5 by typing python2.5. However I'd like to use idle so
require to be able to import _tkinter.
I gather I need to modift the setup.py script in my python directory
but am wary of experimenting since I've had problems with damaging the
default tkinter installation before.
import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/lib-tk/Tkinter.py", line 38, in
<module>
import _tkinter # If this fails your Python may not be configured
for Tk
ImportError: No module named _tkinter
Should I need to download a later version of tkinter and/or should I
alter setup.py in my python install directory and then remake?
If the former how do I ensure I don't overwrite the original tkinter
install thus damaging the many mandriva utilities that rely on
python2.4.3 and if the later what should I be looking for within the
python2.5 installation to point to and what alterations within
setup.py are required?

Oct 30 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Should I need to download a later version of tkinter and/or should I
alter setup.py in my python install directory and then remake?
Neither, nor. You need the Tk header files installed; they probably
come in a package called libtk8.4-dev or some such in your system.
If they are present when setup.py runs, _tkinter will get built
automatically. If you don't have the header files of Tk installed,
no amount of fiddling with setup.py, or getting alternative sources
of tkinter, will actually get you a _tkinter module.

HTH,
Martin
Oct 30 '07 #2

P: n/a
On 30 Oct, 22:36, "Martin v. Lwis" <mar...@v.loewis.dewrote:
Should I need to download a later version of tkinter and/or should I
alter setup.py in my python install directory and then remake?

Neither, nor. You need the Tk header files installed; they probably
come in a package called libtk8.4-dev or some such in your system.
If they are present when setup.py runs, _tkinter will get built
automatically. If you don't have the header files of Tk installed,
no amount of fiddling with setup.py, or getting alternative sources
of tkinter, will actually get you a _tkinter module.

HTH,
Martin

There is indeed such package on the system: libtk8.4-
devel-8.4.13-1mdk, which installs.
However upon running make in the python2.5.1 download directory

INFO: Can't locate Tcl/Tk libs and/or headers
running build_scripts
The only file on the system before installing the above package with a
libtk name is libtk8.4.so.0 in /usr/lib
after the package is installed /usr/lib contains:

0 lrwxrwxrwx 1 root root 13 Oct 31 07:43 libtk8.4.so ->
libtk8.4.so.0*
969 -rwxr-xr-x 1 root root 986216 Apr 21 2006 libtk8.4.so.0*
1 -rwxr-xr-x 1 root root 119 Apr 21 2006 libtk.so*
183 -rw-r--r-- 1 root root 186092 Apr 21 2006 libtkstub8.4.a

however make still complains of the non existance of the the Tcl/Tk
libs and/or headers

copying these file to /usr/local/lib where python2.5 seems to be makes
no difference.


Oct 31 '07 #3

P: n/a
however make still complains of the non existance of the the Tcl/Tk
libs and/or headers
So where it tk.h located?

Regards,
Martin
Oct 31 '07 #4

P: n/a
So where it tk.h located?

tk.h is now in just about every directory called include that could in
anyway be connected with this and indeed it does appear in the make
file printout:

/usr/bin/install -c -m 644 ./Include/sysmodule.h /usr/local/include/
python2.5
/usr/bin/install -c -m 644 ./Include/timefuncs.h /usr/local/include/
python2.5
/usr/bin/install -c -m 644 ./Include/tk.h /usr/local/include/python2.5
/usr/bin/install -c -m 644 ./Include/token.h /usr/local/include/
python2.5
/usr/bin/install -c -m 644 ./Include/traceback.h /usr/local/include/
python2.5

however it still generates the same error message,
I've tried debugging setup.py in the distribution directory with idle
( python2.4.3 versions ) but not surprisingly that doesn't do anything
too impressive, as you would expect.
Short of stuffing lots of print statements in there to actual try and
locate the file names it's failing on I'm at a loss to see where to go
next.

Oct 31 '07 #5

P: n/a
tk.h is now in just about every directory called include that could in
anyway be connected with this and indeed it does appear in the make
file printout:

/usr/bin/install -c -m 644 ./Include/tk.h /usr/local/include/python2.5
How did you get tk.h into the Include directory? You shouldn't manually
copy files around; this will surely break your system and installation
procedures if you don't know exactly what you are doing.

What is the location that your Mandriva package installed tk.h to?
Short of stuffing lots of print statements in there to actual try and
locate the file names it's failing on I'm at a loss to see where to go
next.
tk.h is searched-for in detect_tkinter. Check whether tklib, tcllib,
tcl_includes and tk_includes all get set. This should take only
a single print statement.

Regards,
Martin
Oct 31 '07 #6

P: n/a
tk.h is searched-for in detect_tkinter. Check whether tklib, tcllib,
tcl_includes and tk_includes all get set. This should take only
a single print statement.

Regards,
Martin
Ok I've cleared my increasingly frantic copies out

[root@localhost python2.5]# find / -name tk.h
/usr/include/tk.h
/usr/include/tk8.4.13/generic/tk.h

The slightly more verbose setup.py now reports

lib_dir:['/usr/local/lib', '/lib64', '/usr/lib64', '/lib', '/usr/lib']
Inc_dir: ['./Include', '.', '/usr/local/include', '/home/chris/
Python-2.5.1/Include', '/home/chris /Python-2.5.1', '/usr/
include']
Those TK libraries tcllib=None tklib=None tcl_includes=None
tk_includes=None
INFO: Can't locate Tcl/Tk libs and/or headers

I don't understand why the headers report None as the file tk.h is
in /usr/include ... or is the lack of the word generic more of a
problem?

I also can't work out what the name of the actual libraries are: which
doesn't help much.

The fact that None is reported for everything is a bit confusing.


Oct 31 '07 #7

P: n/a
Those TK libraries tcllib=None tklib=None tcl_includes=None
tk_includes=None
This also contradicts your earlier statement that you have libtk8.4.so
on your machine.

I don't understand why the headers report None as the file tk.h is
in /usr/include ... or is the lack of the word generic more of a
problem?
Please read detect_tkinter in detail: if it already fails to find
tklib or tcllib, it won't check for header files at all.

You should now trace through find_library_file with
print statements. Check whether compiler.find_library_file
returns not None, if yes, report what it returns. Otherwise,
annotate compiler.find_library_file. Print compiler.find_library_file
to see what specific function it is; likely something in
unixccompiler.py.

If so, print out shared, dylib, static, and os.path.exists of each one.

HTH,
Martin
Oct 31 '07 #8

P: n/a
On 31 Oct, 18:46, "Martin v. Lwis" <mar...@v.loewis.dewrote:
Those TK libraries tcllib=None tklib=None tcl_includes=None
tk_includes=None

This also contradicts your earlier statement that you have libtk8.4.so
on your machine.

[chris@localhost Python-2.5.1]$ ls -las /usr/lib/libtk*.*
0 lrwxrwxrwx 1 root root 13 Oct 31 07:43 /usr/lib/libtk8.4.so ->
libtk8.4.so.0*
969 -rwxr-xr-x 1 root root 986216 Apr 21 2006 /usr/lib/libtk8.4.so.0*
1 -rwxr-xr-x 1 root root 119 Apr 21 2006 /usr/lib/libtk.so*
183 -rw-r--r-- 1 root root 186092 Apr 21 2006 /usr/lib/libtkstub8.4.a
lib_dir:['/usr/local/lib', '/lib64', '/usr/lib64', '/lib', '/usr/lib']
Inc_dir:['./Include', '.', '/usr/local/include', '/home/chris/
Python-2.5.1/Include', '/home/chris/Python-2.5.1', '/usr/include']
so if libtk is being looked for it should have found it.

and indeed it did!!
from the print in distutils in unixccompiler.py

shared=/usr/lib/libtk8.4.so
dylib=/usr/lib/libtk8.4.dylib
static=/usr/lib/libtk8.4.a

FOUND!:-/usr/lib/libtk8.4.so
tklib:-/usr/lib/libtk8.4.so
but no tcllib !!!
perhaps that's the problem? Did I assume that it was installed by the
tk mandriva module ?

Perhaps theres a libtcl module to load...
Indeed there is !

787 -rwxr-xr-x 1 root root 800132 Apr 21 2006 /usr/lib/libtcl8.4.so.
0*
1 -rwxr-xr-x 1 root root 122 Apr 21 2006 /usr/lib/libtcl.so*
75 -rw-r--r-- 1 root root 75232 Apr 21 2006 /usr/lib/
libtclstub8.4.a
It would seems so !

Thus after make,su, make install...

[root@localhost Python-2.5.1]# python2.5
Python 2.5.1 (r251:54863, Oct 30 2007, 19:01:24)
[GCC 4.1.1 20060724 (prerelease) (4.1.1-3mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>import _tkinter

Thank you very much for your help Martin. much learned.
Nov 1 '07 #9

P: n/a
but no tcllib !!!
perhaps that's the problem? Did I assume that it was installed by the
tk mandriva module ?
I see. I would have never guessed that you can manage to install
Tk but not Tcl on Mandriva...

Regards,
Martin
Nov 1 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.