[SOLVED] TK/TCL not installed Properly... (bug fix)


Kosmos

Member
Joined
Apr 10, 2012
Messages
228
I have the 4 core packages of Python, Tkinter, TK & TCL installed... And am working through the book "Python for Kids".

However, when I try something like this...

>>> import turtle

>>> turtle.forward(50)

I get an error about TK/TCL not being properly installed.

What are all the ipks that I need to install with opkg to run python/tk/tcl natively on my SD-installed SZ1.52 OS?

For GCC I ran the following

  • opkg update
  • opkg install gcc g++ cpp binutils
  • opkg install gcc-symlinks g++-symlinks cpp-symlinks
  • opkg install libstdc++6 libstdc++-dev libgcc1
  • opkg install gcc-doc
  • opkg install libssp0

So that I can go through my GCC/C++ tutorials/lessons.

I would like to do the same for Python. As well as be able to run games and other programs natively on my pandora. I have the Dev-Tools kits but want to have the basics also installed natively via opkg for use in bash.
 
Last edited by a moderator:
You can have all that already installed in the code::blocks PND, using the command line. But it's not installed nativelly..
 
Yes your are right but as I stated above. I need it installed natively as I did with GCC for some native microcontroller work after I complete the lessons.
 
Anyway, if you have GCC insalled, I suggest you install what you need from sources.

basicaly (don't know your level of unix) get the tar ball you need, untar soumewhere



Code:
tar xzf Python-src.2.7.3.tar.gz

 

for example, it will expand all the sources in a folder of the same name. go inside and then just

 



Code:
./configure

to configure the compilation to your environnement. Use "--help" to get options.

If all goes well, do a 



Code:
make

and wait for the compile to finish.

And then just



Code:
sudo make install
to install "natively".

Be aware that you MUST be running your OS from a SDCard, as the Flash is not large enough to get GCC, Python, TCL/TK and so on... (check, but less than 100Mo are avaible after a SuperZaxxon install). That why all is stored on PND.
 
I have Python installed and working from opkg. Will installing from sources solve the TK/TCL problem that I am having?

I am currently not an expert but not a noob either in Linux as it is now my primary OS.
 
Well, installing from source is an interesting experience. You should try :) .

Also, they are many option for Python to play with. I don't remember the options of TCL/TK, but it install from source quite easily IIRC.
 
OK I tried "opkg install tk-dev tk-dbg tcl-dev tcl-dbg" as this was part of a tk bug known in 2.6

Does not help/.

Then I downloaded python-2.73 source and just ran ./configure

I get an an error the /lib/cpp fails sanity check.

I looked in config.log and found this:

Syntax Error

configure: 4084: /lib/cpp conftest.c

 "GCC Failed Sanity Check"

etc etc

Recommendations? This failed-configure is not creating a makefile.

FOUND IT:

Have to install these:

opkg install linux-libc-headers-dev --force-overwrite

opkg install linux-libc-headers-dbg --force-overwrite

gcc is now sane & python "configures" properly. (step 1)
 
Last edited by a moderator:
Great, now I learn that "make" is not installed!

Cool. So off to install make(-dev/-dbg/-doc)

now 'making' pythons...

NOTE:

While building (step 2), I briefly saw "TK/TCL Libraries not found" flash across the screen. Not sure if this is a show stopper.

I ran opkg install tk(-dev/-dbg) & tcl(-dev/-dbg) previously so that I am at a loss.

I will test turtle when it finishes build/install, and let you know.
 
Last edited by a moderator:
Python 2.7.3 installed but TK/TCL is even more broke.

Now even this gives an error:

$ python

>>>import turtle

     File /usr/local/lib/python2.7/lib-tk/turtle.py, line 107, in <module> import TKinter as TK

     File /usr/local/lib/python2.7/lib-tk/TKinter.py, line 39, in <module> import _tkinter # If this fails your Python may not be configured for TK

ImportError: No module named _tkinter

UPDATE:

Temporarily removing /usr/local to return to Python 2.6 and reinstalling all the packages in opkg, I still get python without tk support even though /usr/lib/tk8.4 and /usr/lib/tcl8.4 both exists and tk.tcl exists as well. I still get errors about it not finding tk.tcl

I have been all over the net looking for these errors and seeing various similar problems with ubuntu, python 2.6 & 3.2 etc but no workable solutions for this in Angstrom!

HELP!
 
Last edited by a moderator:
The TCL/TK from code::blocks is functional, but I don't really remember which options I used, for Python 2.7.3 and for TCL/TK 8.5.13. I have to check the config.log of each packages:

for Python 2.7.3



Code:
./configure --prefix=/mnt/utmp/codeblocks/usr --with-threads --disable-shared

 

for tcl 8.5.13, I use



Code:
unix/configure --enable-threads --prefix=/mnt/utmp/codeblocks/usr

 

for tk 8.5.13, same thing



Code:
unix/configure --enable-threads --prefix=/mnt/utmp/codeblocks/usr

Of course, the "--prefix=/mnt/utmp/codeblocks/usr" is useless for you, just opmit the --prefix option and it will use standard system path.

I hope it helps.
 
I got my Pandora recently and ran into a TK/TCL problem with python.  After installing tk and tcl the error changed.

Python was complaining about being unable to bind the mouse wheel for some gtk gui elements.  I commented out the bindings (I don't even know where the mouse wheel is on the Pandora) and things started working for me.

Start with:

Code:
cd /usr/lib/tk8.4
grep MouseWheel *
 
The TCL/TK from code::blocks is functional, but I don't really remember which options I used, for Python 2.7.3 and for TCL/TK 8.5.13. I have to check the config.log of each packages:

for Python 2.7.3


./configure --prefix=/mnt/utmp/codeblocks/usr --with-threads --disable-shared


for tcl 8.5.13, I use


unix/configure --enable-threads --prefix=/mnt/utmp/codeblocks/usr


for tk 8.5.13, same thing


unix/configure --enable-threads --prefix=/mnt/utmp/codeblocks/usr


Of course, the "--prefix=/mnt/utmp/codeblocks/usr" is useless for you, just opmit the --prefix option and it will use standard system path.

I hope it helps.
"./configure  --enable-threads" for Python, I understand though it rejects that option.

But the "unix/configure" makes no sense to me and I can not find anything online to explain it. Sorry.

What and Where do I configure TK and TCL to work with Python?
 
Last edited by a moderator:
In my TCL & TK folder, the "configure" file is in a subfolder named "unix", but I have launched it from the root of TCL.
 
Temporarily removing /usr/local to return to Python 2.6 and reinstalling all the packages in opkg, I still get python without tk support even though /usr/lib/tk8.4 and /usr/lib/tcl8.4 both exists and tk.tcl exists as well. I still get errors about it not finding tk.tcl
When you build Python, it looks for the presence of the TK development files and adds the _tkinter built-in

module if it finds them.  You should go into your Modules subdir of your Python source tree and see if _tkinter.o was built.

If it wasn't, your Python wasn't built with an interface into tcl/tk and you need to address this before anything else

will work.

In parallel with this, you need to make sure you have correctly installed tcl/tk.  If you built tcl8.6/tk8.6 then you should run the commands "tclsh8.6" and "with8.6" and make sure they start without errors (the former proves your tcl is OK, the latter that your tk is OK).

And in Python just do "import _tkinter".  When that works you know you've built a Python with TK support.

If it'll help you with a starting point, here's a snapshot of my /usr/local based python2.7 with tcl/tk.  It can run

PySolFC (which is why I originally did it :->) and should give you a point of comparison for your own port.

    http://www.vsta.org/andy/pickup/py_tcl_tk.tar.gz

Hope this helps...

Andy
 
In my TCL & TK folder, the "configure" file is in a subfolder named "unix", but I have launched it from the root of TCL.
As stated above, I installed TCVL & TK from the Angstrom repo via OPKG as well. And neiither the tk8.4 or tcl8.4 directories have a subdirectory 'unix' or configure.

So, should I get a source for tcl and tk from sonewhere? then configure/make/install each of them before installing python?

Can someone give me the order to do it right?

Its an adventure alright!
 
Temporarily removing /usr/local to return to Python 2.6 and reinstalling all the packages in opkg, I still get python without tk support even though /usr/lib/tk8.4 and /usr/lib/tcl8.4 both exists and tk.tcl exists as well. I still get errors about it not finding tk.tcl
When you build Python, it looks for the presence of the TK development files and adds the _tkinter built-in

module if it finds them.  You should go into your Modules subdir of your Python source tree and see if _tkinter.o was built.

If it wasn't, your Python wasn't built with an interface into tcl/tk and you need to address this before anything else

will work.

In parallel with this, you need to make sure you have correctly installed tcl/tk.  If you built tcl8.6/tk8.6 then you should run the commands "tclsh8.6" and "with8.6" and make sure they start without errors (the former proves your tcl is OK, the latter that your tk is OK).

And in Python just do "import _tkinter".  When that works you know you've built a Python with TK support.

If it'll help you with a starting point, here's a snapshot of my /usr/local based python2.7 with tcl/tk.  It can run

PySolFC (which is why I originally did it :->) and should give you a point of comparison for your own port.

    http://www.vsta.org/andy/pickup/py_tcl_tk.tar.gz

Hope this helps...

Andy
I unzipped the file to /usr/local and type 'python2.7'

Python loads correctly but "import turtle" gives the same errors about TK not being configured...
 
Wouldn't you need some interface from python to tk? Like tk-python or something (don't know if this is an actual package).
 
its called python-tkinter.    got it.

What about python-pygtk. Would that be relevant or not?

In PanDebian I simply made sure Python, Python-TK and IDLE were installed and that was it. Whatever dependancies were needed got installed.

This is a bit more complicated. Something needs to be manually configured and I do not know what.

I love PanDebian but some of my goals involve a native Angstrom solution. And getting Python and TK to bind, is proving difficult.
 
Last edited by a moderator:
OK, I downloaded TK8.4 and TCL8.4 sources.

I ran './configure && make && make install' from the unix directory of TCL then for TK

I edited the Python onfigure setup.py and added /usr/local/lib to the include directories to hopefully recognize the new tcl/tk.

I then ran './configure && make && make install' for the source of Python 2.7

'modules/_tkinter.o' was not created

I searched config.log for "tk" to search for an obvious error. "tk" is not in the log.

Then I went into python and tried importing the turtle module again. Still getting "no module name _tkinter"

But I expected that!

===============

UPDATE:

Found Modules/setup and uncommented/edited the TKinter section paths (see below).

Running configure now.

Running make now.

Checking for Modules/_tkinter.o

It's there BUT when I run make, I get this error now.

./python: error while loading shared libraries: libtcl8.4.so: cannot open shared object file: No such file or directory
make: *** [sharedmods] Error 127


but it is installed at

/usr/local/lib/libtcl8.4.so

The following is the modified relevant section of the modules/setup file

# The _tkinter module.
#
# The command for _tkinter is long and site specific.  Please
# uncomment and/or edit those parts as indicated.

# *** Always uncomment this (leave the leading underscore in!):
 _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
# *** Uncomment and edit to reflect where your Tcl/Tk libraries are:
    -L/usr/local/lib \
    -L/usr/lib \  # Tried with and without this line
# *** Uncomment and edit to reflect where your Tcl/Tk headers are:
    -I/usr/local/include \
    -I/usr/include \  # Tried with and without this line
# *** Uncomment and edit to reflect where your X11 header files are:
    -I/usr/include/X11 \
# *** Uncomment and edit to reflect your Tcl/Tk versions:
    -ltk8.4 -ltcl8.4 \
# *** Uncomment and edit to reflect where your X11 libraries are:
    -L/usr/lib/X11 \
# *** Always uncomment this; X11 libraries to link with:
    -lX11

Progress and I am taking notes of this.I temporarily did this:

cp /usr/local/lib/libtcl8.4.so /usr/lib

The compiling error is gone but Python still does not see the TK or tkinter support.

I wish someone could understand what is it that is broke from the beginning and offer step-by-step guide to properly installing Python with TK support.

Anyway, I have learned a lot and no longer fear installing from Source.
 
Last edited by a moderator:
Andy has been a big help and he found the solution to be one which many others had also and a bit obscure.

http://www.tek-tips.com/viewthread.cfm?qid=1619488

So, I posted him the error I finally was getting after an attempt to import turtle and then turtle.forward(50)

/usr/local/lib/tk8.4/tk.tcl: no event type or button # or keysym
no event type or button # or keysym
    while executing
"bind Listbox <MouseWheel>


 ... ... ...
    invoked from within
"if {[tk windowingsystem] eq "classic" || [tk windowingsystem] eq "aqua"} {
    bind Listbox <MouseWheel> {
        %W yview scroll [expr {- (%D)}] uni..."
    (file "/usr/local/lib/tk8.4/listbox.tcl" line 181)
    invoked from within
"source /usr/local/lib/tk8.4/listbox.tcl"


QUOTE modified from above link explains:

The proximate cause is "MouseWheel" event type is not recognized.  One fix, if you don't care about the stupid MouseWheel, is just to comment out (with "#") the entire "bind" for MouseWheel events.  This happens at lines 178 through 198 of "listbox.tcl", and lines 453 through 474 of "text.tcl".  Both files in the tk support directory path listed in the error message, here:

/usr/local/lib/tk8.4/listbox.tcl
/usr/local/lib/tk8.4/text.tcl

I also repaired the default files for Python2.6 installed via opkg

/usr/lib/tk8.4/listbox.tcl
/usr/lib/tk8.4/text.tcl

I commented these out, and now have working tk applications!  

The ultimate cause of this error is unknown, possibly due to a mismatch between Tcl/Tk at install time or run time.  I got it building the X11 version of Tk (in "unix/"), but commenting out the "MouseWheel" sections fixed it.
 
Last edited by a moderator:
Back
Top