sage with tkinter (or some graphics backend?) on Mac OS X

89 views
Skip to first unread message

Adam

unread,
May 20, 2009, 6:03:28 PM5/20/09
to sage-support
Hi folks,
My question is sort of a repeat of this thread:
http://www.mail-archive.com/sage-s...@googlegroups.com/msg08432.html,
but with some additional failures.
I have not been able to compile my own tcl & tk on Leopard. So I
can't follow the instructions presented above directly.
In short, is there any (straightforward?) way to get sage to
recognize tkinter on Mac? I'm interested in using pylab from within
sage, so if there's an alternate path to using pylab I would be happy
with that.

Thanks,
Adam

William Stein

unread,
May 20, 2009, 6:42:18 PM5/20/09
to sage-s...@googlegroups.com

Here's how to use pylab in the notebook:

sage: from pylab import *
sage: t = arange(0.0, 2.0, 0.01)
sage: s = sin(2*pi*t)
sage: P = plot(t, s, linewidth=1.0)
sage: xl = xlabel('time (s)')
sage: yl = ylabel('voltage (mV)')
sage: t = title('About as simple as it gets, folks')
sage: grid(True)
sage: savefig('sage.png')

Adam

unread,
May 20, 2009, 10:48:53 PM5/20/09
to sage-support
The problem is that I can't import pylab because _tkinter isn't
recognized:
sage: import pylab
<lots of stuff chopped out>
ImportError: No module named _tkinter

Adam

On May 20, 4:42 pm, William Stein <wst...@gmail.com> wrote:

mabshoff

unread,
May 20, 2009, 11:10:50 PM5/20/09
to sage-support


On May 20, 7:48 pm, Adam <keflav...@gmail.com> wrote:
> The problem is that I can't import pylab because _tkinter isn't
> recognized:
> sage: import pylab
> <lots of stuff chopped out>
> ImportError: No module named _tkinter
>
> Adam

We disable the tk backend in MPL on all platforms. To work around this
set

SAGE_MATPLOTLIB_GUI

to something not "no" in the shell and force a rebuild of the
matplotlib.spkg.

Cheers,

Michael

Adam

unread,
May 22, 2009, 10:30:39 AM5/22/09
to sage-support
Thanks Michael. I've tried doing as you said, but still no luck.

export SAGE_MATPLOTLIB_GUI=yes
./sage -f python-2.5.2.p9 matplotlib-0.98.5.3rc0-svn6910.p3

but I get the same error. Any idea what else I should try?

Thanks,
Adam

On May 20, 9:10 pm, mabshoff <Michael.Absh...@mathematik.uni-

mabshoff

unread,
May 22, 2009, 10:35:20 AM5/22/09
to sage-support


On May 22, 7:30 am, Adam <keflav...@gmail.com> wrote:

Hi Adam,

> Thanks Michael.  I've tried doing as you said, but still no luck.
>
> export SAGE_MATPLOTLIB_GUI=yes
> ./sage -f python-2.5.2.p9 matplotlib-0.98.5.3rc0-svn6910.p3
>
> but I get the same error.  Any idea what else I should try?

See http://trac.sagemath.org/sage_trac/ticket/4970 - I still have to
touch the python.spkg for 4.0, so I might find time to integrate the
fix. No promises, but a reminder in a couple days might help ;)

> Thanks,
> Adam

Cheers,

Michael

Adam

unread,
May 22, 2009, 11:19:12 AM5/22/09
to sage-support
OK, followed the instructions on that ticket to the best of my
ability. However, I'm running in to all sorts of problems:
1. I can compile tcl but not tk from source. I'm trying to track down
the error but I don't know if it will happen: error: #error Tk 8.5
must be compiled with tcl.h from Tcl 8.5
2. running ./spkg-install in python-2.5.2.p9 after modifying setup.py
dies with the error: ImportError: No module named _md5 (running sage -
f python-2.5.2.p9 works)

I also tried installing the activestate tcl/tk, but from the trac
ticket I'm not sure if that will work - are the configure options
passed to the tcl/tk source install important? It would be nice not
to have to deal with the tk install errors too.

Thanks again,
Adam

On May 22, 8:35 am, mabshoff <Michael.Absh...@mathematik.uni-
dortmund.de> wrote:
> On May 22, 7:30 am, Adam <keflav...@gmail.com> wrote:
>
> Hi Adam,
>
> > Thanks Michael.  I've tried doing as you said, but still no luck.
>
> > export SAGE_MATPLOTLIB_GUI=yes
> > ./sage -f python-2.5.2.p9 matplotlib-0.98.5.3rc0-svn6910.p3
>
> > but I get the same error.  Any idea what else I should try?
>
> Seehttp://trac.sagemath.org/sage_trac/ticket/4970- I still have to

Adam

unread,
May 30, 2009, 1:04:41 PM5/30/09
to sage-support
Here's what I tried:

download tcl8.5.7-src.tar.gz and tk8.5.7-src.tar.gz from
http://www.tcl.tk/software/tcltk/download.html
run ./configure --enable-framework --disable-xft in the unix/
subdirectory of tcl, then make & make install as normal
run ./configure --enable-framework --disable-xft in the unix/
subdirectory of tk, then make & make install as normal
/Applications/sage/sage -sh
cd /Applications/sage/spkg/standard/python-2.5.2.p9/src/
[edit setup.py as suggested at http://trac.sagemath.org/sage_trac/ticket/4970]
./spkg-install

ERROR:
/usr/bin/install -c -m 644 ./Misc/python.man \
/Applications/sage/local/share/man/man1/python.1
Copying 64 bit OSX specific pymactoolbox.h
Sleeping for three seconds before testing python
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Applications/sage/local/lib/python2.5/md5.py", line 6, in
<module>
from hashlib import md5
File "/Applications/sage/local/lib/python2.5/hashlib.py", line 133,
in <module>
md5 = __get_builtin_constructor('md5')
File "/Applications/sage/local/lib/python2.5/hashlib.py", line 60,
in __get_builtin_constructor
import _md5
ImportError: No module named _md5
md5 module failed to import

OK, that failed, trying something different...
Download tcltk from: http://nullhomotopie.de/tcltk8.5.7.spkg (as per
instructions on http://wiki.sagemath.org/Yacop)

./sage -f spkg/optional/tcltk8.5.7.spkg spkg/standard/
matplotlib-0.98.5.3rc0-svn6910.p3 spkg/standard/python-2.5.2.p9

Then try to import _tkinter....:
/Applications/sage$ ./sage -c "import _tkinter"
Traceback (most recent call last):
File "/Applications/sage/local/bin/sage-eval", line 14, in <module>
eval(compile(s,'<cmdline>','exec'))
File "<cmdline>", line 1, in <module>
ImportError: No module named _tkinter

So I'm still stuck. Any ideas?

Thanks,
Adam

Jorge E. ´Sanchez Sanchez

unread,
May 30, 2009, 2:57:01 PM5/30/09
to sage-s...@googlegroups.com
Adam,
 
   according to the FAQ No. 3.9: "It may be that you have Tcl/Tk installed and that your system's python recognizes it, but Sage's python does not, To fix that, install the tcl/tk development library (something like tk8.5-dev)."
   Then, you can test if this is the case giving:
   sage: import _tkinter
   sage: import Tkinter
   if it does not complain your SAGE's python recognizes it. If it does, you need to reinstall your SAGE's Python:
   sage -f python-2.5.2.p9
and make the test again.
   sage: import _tkinter
   sage: import Tkinter.
   It should work now.
 
Regards,
Jorge
 
> Date: Sat, 30 May 2009 10:04:41 -0700
> Subject: [sage-support] Re: sage with tkinter (or some graphics backend?) on Mac OS X
> From: kefl...@gmail.com
> To: sage-s...@googlegroups.com

Adam

unread,
Jun 1, 2009, 9:49:51 AM6/1/09
to sage-support
I'm on a mac. There is no 'tk8.5-dev' package to install with fink.
I've tried installing the activstate tcl/tk and their devtools. I've
also tried installing tcl/tk from source. Is there anything else I
can try?

Certainly, following the FAQ, the instructions on the trac ticket
above, or other hints posted on this thread should work, but they
haven't yet.

Adam

Christian Nassau

unread,
Jun 1, 2009, 10:42:52 AM6/1/09
to sage-s...@googlegroups.com
Getting python to pick up the right Tcl on the Mac has been (still is) a
real PITA. With the Yacop project we've now switched to using a private
fork "Tkynter" of Tkinter with a much simplified build script. It just
*might* be the case that something similar could work for you.

I would recommend to use the ActiveTcl Tcl8.5 installation, since that
is a well-maintained distribution which also gives you many add-on's
that you might find useful. You will need to know the location of their
headers and libraries, though. One way to find out about this is to
start their "wish8.5" and ask for "info library". That should give you
an idea where to look for "tcl.h" and "libtcl<whatever>", "libtk<whatever>".

Then if you unpack yesterday's

http://nullhomotopie.de/yacop1.0.spkg

you'll find a directory Tkynter-1.0 which is pretty minimalistic:

cn@jehova:~/sagepkgs/yacop1.0> du -a Tkynter-1.0/
4 Tkynter-1.0/PKG-INFO
156 Tkynter-1.0/Tkynter.py
72 Tkynter-1.0/_tkynter.c
4 Tkynter-1.0/setup.py
8 Tkynter-1.0/tkappinit.c

In theory a simple "python Tkynter-1.0/setup.py install" would install
that package. But you should be aware of three things first:

1) you have to manually edit "setup.py" to make it pick up the ActiveTcl
files. Once you know which these files are, this shouldn't be a big
deal, since setup.py is very small:

> from distutils.core import setup, Extension
> import os
> setup(name='Tkynter',
> version='1.0',
> ext_modules=[Extension('_tkynter', ['_tkynter.c', 'tkappinit.c'],
> define_macros=[('WITH_APPINIT', 1)],
> include_dirs = [os.environ.get("SAGE_LOCAL") + os.sep + "include",
> os.environ.get("SAGE_LOCAL") + os.sep + "include" + os.sep + "python2.5"],
> libraries = ["tcl8.5","tk8.5"],
> library_dirs = [os.environ.get("SAGE_LOCAL") + os.sep + "lib"],
> )],
> py_modules=['Tkynter']
> )

2) Obviously you should rename "Tkynter" back to "Tkinter". That change
also affects Tkynter.py, _tkynter.c, and tkappinit.c. A simple "sed
's/kynter/kinter/g" should do the trick. Or just copy the original files
from the python source directory.

3) Last thing is that "Tkynter" is an *incomplete* fork of Tkinter. The
original has an extra directory "local/lib/python2.5/lib-tk" with a
couple of python scripts:

cn@jehova:/waste/cn/sage-3.4-linux-openSUSE_11.1_x86_64-x86_64-Linux> ls
local/lib/python2.5/lib-tk/*py
local/lib/python2.5/lib-tk/Canvas.py
local/lib/python2.5/lib-tk/Dialog.py
local/lib/python2.5/lib-tk/FileDialog.py
local/lib/python2.5/lib-tk/FixTk.py
local/lib/python2.5/lib-tk/ScrolledText.py
local/lib/python2.5/lib-tk/SimpleDialog.py
local/lib/python2.5/lib-tk/Tix.py
local/lib/python2.5/lib-tk/tkColorChooser.py
local/lib/python2.5/lib-tk/tkCommonDialog.py
local/lib/python2.5/lib-tk/Tkconstants.py
local/lib/python2.5/lib-tk/Tkdnd.py
local/lib/python2.5/lib-tk/tkFileDialog.py
local/lib/python2.5/lib-tk/tkFont.py
local/lib/python2.5/lib-tk/Tkinter.py
local/lib/python2.5/lib-tk/tkMessageBox.py
local/lib/python2.5/lib-tk/tkSimpleDialog.py
local/lib/python2.5/lib-tk/turtle.py

You might have to copy these over manually.

Hope this helps,
C.

Adam

unread,
Jun 1, 2009, 11:00:16 AM6/1/09
to sage-support
That is quite a process, but it's good to know that I'm not just being
obtuse.

That said, I'll now be obtuse:
I found the path to the headers as you suggested...
/Library/Frameworks/Tcl.framework/Headers
or
/Library/Frameworks/Tcl.framework/Versions/8.5/Headers/

But I don't understand what I need to modify in setup.py - the
include_dirs and library_dirs look like python include directories to
me, not the tcl/tk path. Am I supposed to add a new line specifying
where to search for the headers? Apologies for the dumb question - I
am not very familiar with the internal workings of setup.py 's.

I think I can manage the tkynter->tkinter change, though to be clear:
I should also rename Tkynter.py to Tkinter.py and _tkynter.c to
_tkinter.c?

And, finally, I should copy the python2.5/lib-tk/*py files to the
Tkynter-1.0 directory before running "python setup.py install" (or
probably "sage setup.py install"?)

Thanks!
Adam

Christian Nassau

unread,
Jun 1, 2009, 11:38:41 AM6/1/09
to sage-s...@googlegroups.com
Hi Adam,

I've just uploaded a new tar file which also includes the lib-tk folder.

http://nullhomotopie.de/tkinter.tar.gz

This now has the following setup.py:

> from distutils.core import setup, Extension
> import os
> import glob
> setup(name='Tkinter',
> version='1.0',
> ext_modules=[Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
> define_macros=[('WITH_APPINIT', 1)],
> include_dirs = ['/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers/'],
> libraries = ["tcl8.4","tk8.4"],
> library_dirs = ['/usr/lib']
> )],
> py_modules=['lib-tk/Tkinter'],
> data_files=[('lib/python2.5/lib-tk',glob.glob('lib-tk/*py'))]
> )

It seems to build on my MacMini against the pre-installed Tcl8.4 using

./sage -sh
cd Tkinter-1.0
python setup.py install

You might have to change the 8.4 to 8.5, of course. I'm also not 100%
sure whether the lib-tk folder went to the right place... you'll find it
out ;-)

Good luck,
C.

Adam

unread,
Jun 1, 2009, 11:49:42 AM6/1/09
to sage-support
I was able to follow your install instructions, and got a new error in
sage this time:

eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ sage
setup.py install
running install
running build
running build_py
running build_ext
building '_tkinter' extension
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/Library/Frameworks/Tcl.framework/Headers -I/Applications/sage/local/
include/python2.5 -c _tkinter.c -o build/temp.macosx-10.3-i386-2.5/
_tkinter.o
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/Library/Frameworks/Tcl.framework/Headers -I/Applications/sage/local/
include/python2.5 -c tkappinit.c -o build/temp.macosx-10.3-i386-2.5/
tkappinit.o
gcc -m64 -L/Applications/sage/local/lib -bundle -undefined
dynamic_lookup build/temp.macosx-10.3-i386-2.5/_tkinter.o build/
temp.macosx-10.3-i386-2.5/tkappinit.o -L/usr/lib/ -ltcl8.5 -ltk8.5 -o
build/lib.macosx-10.3-i386-2.5/_tkinter.so
ld warning: in /Applications/sage/local/lib/libtcl8.5.dylib, file is
not of required architecture
ld warning: in /Applications/sage/local/lib/libtk8.5.dylib, file is
not of required architecture
running install_lib
copying build/lib.macosx-10.3-i386-2.5/_tkinter.so -> /Applications/
sage/local/lib/python2.5/site-packages
creating /Applications/sage/local/lib/python2.5/site-packages/lib-tk
copying build/lib.macosx-10.3-i386-2.5/lib-tk/Tkinter.py -> /
Applications/sage/local/lib/python2.5/site-packages/lib-tk
byte-compiling /Applications/sage/local/lib/python2.5/site-packages/
lib-tk/Tkinter.py to Tkinter.pyc
running install_data
copying lib-tk/Canvas.py -> /Applications/sage/local/lib/python2.5/lib-
tk
copying lib-tk/Dialog.py -> /Applications/sage/local/lib/python2.5/lib-
tk
copying lib-tk/FileDialog.py -> /Applications/sage/local/lib/python2.5/
lib-tk
copying lib-tk/FixTk.py -> /Applications/sage/local/lib/python2.5/lib-
tk
copying lib-tk/ScrolledText.py -> /Applications/sage/local/lib/
python2.5/lib-tk
copying lib-tk/SimpleDialog.py -> /Applications/sage/local/lib/
python2.5/lib-tk
copying lib-tk/Tix.py -> /Applications/sage/local/lib/python2.5/lib-tk
copying lib-tk/tkColorChooser.py -> /Applications/sage/local/lib/
python2.5/lib-tk
copying lib-tk/tkCommonDialog.py -> /Applications/sage/local/lib/
python2.5/lib-tk
copying lib-tk/Tkconstants.py -> /Applications/sage/local/lib/
python2.5/lib-tk
copying lib-tk/Tkdnd.py -> /Applications/sage/local/lib/python2.5/lib-
tk
copying lib-tk/tkFileDialog.py -> /Applications/sage/local/lib/
python2.5/lib-tk
copying lib-tk/tkFont.py -> /Applications/sage/local/lib/python2.5/lib-
tk
copying lib-tk/Tkinter.py -> /Applications/sage/local/lib/python2.5/
lib-tk
copying lib-tk/tkMessageBox.py -> /Applications/sage/local/lib/
python2.5/lib-tk
copying lib-tk/tkSimpleDialog.py -> /Applications/sage/local/lib/
python2.5/lib-tk
copying lib-tk/turtle.py -> /Applications/sage/local/lib/python2.5/lib-
tk
running install_egg_info
Writing /Applications/sage/local/lib/python2.5/site-packages/
Tkinter-1.0-py2.5.egg-info
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ sage -c
"import _tkinter"
Traceback (most recent call last):
File "/Applications/sage/local/bin/sage-eval", line 14, in <module>
eval(compile(s,'<cmdline>','exec'))
File "<cmdline>", line 1, in <module>
ImportError: dlopen(/Applications/sage/local/lib/python2.5/site-
packages/_tkinter.so, 2): Symbol not found: _TclFreeObj
Referenced from: /Applications/sage/local/lib/python2.5/site-
packages/_tkinter.so
Expected in: dynamic lookup

Does that mean there was a problem with the lib-tk/ folder?

Again, thanks,
Adam


my setup.py:

from distutils.core import setup, Extension
import os
import glob
setup(name='Tkinter',
version='1.0',
ext_modules=[Extension('_tkinter', ['_tkinter.c',
'tkappinit.c'],
define_macros=[('WITH_APPINIT', 1)],
include_dirs = ['/Library/Frameworks/
Tcl.framework/Headers'],
libraries = ["tcl8.5","tk8.5"],
library_dirs = ['/usr/lib/']

Christian Nassau

unread,
Jun 1, 2009, 12:00:01 PM6/1/09
to sage-s...@googlegroups.com
Adam wrote:
> gcc -m64 -L/Applications/sage/local/lib -bundle -undefined
> dynamic_lookup build/temp.macosx-10.3-i386-2.5/_tkinter.o build/
> temp.macosx-10.3-i386-2.5/tkappinit.o -L/usr/lib/ -ltcl8.5 -ltk8.5 -o
> build/lib.macosx-10.3-i386-2.5/_tkinter.so
> ld warning: in /Applications/sage/local/lib/libtcl8.5.dylib, file is
> not of required architecture
> ld warning: in /Applications/sage/local/lib/libtk8.5.dylib, file is
> not of required architecture

You should probably remove the libtcl8.5.dylib and libtk8.5.dylib under
/Applications/sage/local/lib/: these files are probably from the Yacop
Tcl installation. We really want to link against the libtcl/libtk under
/usr/lib instead.

You should probably also remove

/Applications/sage/local/lib/python2.5/site-packages/Tkinter-1.0-py2.5.egg-info
/Applications/sage/local/lib/python2.5/site-packages/_tkinter.so

to make sure the next installation attempt really builds them from scratch.

HTH,
C.

Adam

unread,
Jun 1, 2009, 12:22:01 PM6/1/09
to sage-support
Same problem, but with a different dylib file selected:
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ sage
setup.py install
running install
running build
running build_py
creating build
creating build/lib.macosx-10.3-i386-2.5
creating build/lib.macosx-10.3-i386-2.5/lib-tk
copying lib-tk/Tkinter.py -> build/lib.macosx-10.3-i386-2.5/lib-tk
running build_ext
building '_tkinter' extension
creating build/temp.macosx-10.3-i386-2.5
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/Library/Frameworks/Tcl.framework/Headers -I/Applications/sage/local/
include/python2.5 -c _tkinter.c -o build/temp.macosx-10.3-i386-2.5/
_tkinter.o
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/Library/Frameworks/Tcl.framework/Headers -I/Applications/sage/local/
include/python2.5 -c tkappinit.c -o build/temp.macosx-10.3-i386-2.5/
tkappinit.o
gcc -m64 -L/Applications/sage/local/lib -bundle -undefined
dynamic_lookup build/temp.macosx-10.3-i386-2.5/_tkinter.o build/
temp.macosx-10.3-i386-2.5/tkappinit.o -L/usr/lib/ -ltcl8.5 -ltk8.5 -o
build/lib.macosx-10.3-i386-2.5/_tkinter.so
ld warning: in /usr/local/lib/libtcl8.5.dylib, file is not of required
architecture
ld warning: in /usr/local/lib/libtk8.5.dylib, file is not of required
architecture
running install_lib
copying build/lib.macosx-10.3-i386-2.5/_tkinter.so -> /Applications/
sage/local/lib/python2.5/site-packages
running install_data
running install_egg_info
Removing /Applications/sage/local/lib/python2.5/site-packages/
Tkinter-1.0-py2.5.egg-info
Writing /Applications/sage/local/lib/python2.5/site-packages/
Tkinter-1.0-py2.5.egg-info
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ sage -c
"import Tkinter"
Traceback (most recent call last):
File "/Applications/sage/local/bin/sage-eval", line 14, in <module>
eval(compile(s,'<cmdline>','exec'))
File "<cmdline>", line 1, in <module>
File "/Applications/sage/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: dlopen(/Applications/sage/local/lib/python2.5/site-
packages/_tkinter.so, 2): Symbol not found: _TclFreeObj
Referenced from: /Applications/sage/local/lib/python2.5/site-
packages/_tkinter.so
Expected in: dynamic lookup

I also tried using your setup.py to use the system default tkinter,
but for some reason setup.py is trying to use /usr/local/include
instead of /usr/include and is therefore running into a conflict
between 8.4 and 8.5:
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ sage
setup.py install
running install
running build
running build_py
running build_ext
building '_tkinter' extension
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers/ -I/usr/
include/ -I/Applications/sage/local/include/python2.5 -c _tkinter.c -o
build/temp.macosx-10.3-i386-2.5/_tkinter.o
In file included from _tkinter.c:67:
/usr/local/include/tk.h:23:3: error: #error Tk 8.5 must be compiled
with tcl.h from Tcl 8.5
error: command 'gcc' failed with exit status 1

I also tried adding '/usr/include/' to the include_dirs dict entry,
but it didn't work. So I moved /usr/local/include/tk.h to tk.noh to
hide it, and then the install worked but I ran into yet another error
when importing tkinter:

eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ sage
setup_8.4.py install
running install
running build
running build_py
creating build
creating build/lib.macosx-10.3-i386-2.5
creating build/lib.macosx-10.3-i386-2.5/lib-tk
copying lib-tk/Tkinter.py -> build/lib.macosx-10.3-i386-2.5/lib-tk
running build_ext
building '_tkinter' extension
creating build/temp.macosx-10.3-i386-2.5
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers/ -I/usr/
include/ -I/Applications/sage/local/include/python2.5 -c _tkinter.c -o
build/temp.macosx-10.3-i386-2.5/_tkinter.o
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers/ -I/usr/
include/ -I/Applications/sage/local/include/python2.5 -c tkappinit.c -
o build/temp.macosx-10.3-i386-2.5/tkappinit.o
gcc -m64 -L/Applications/sage/local/lib -bundle -undefined
dynamic_lookup build/temp.macosx-10.3-i386-2.5/_tkinter.o build/
temp.macosx-10.3-i386-2.5/tkappinit.o -L/usr/lib/ -ltcl8.4 -ltk8.4 -o
build/lib.macosx-10.3-i386-2.5/_tkinter.so
ld warning: in /usr/lib//libtk8.4.dylib, missing required architecture
x86_64 in file
running install_lib
copying build/lib.macosx-10.3-i386-2.5/_tkinter.so -> /Applications/
sage/local/lib/python2.5/site-packages
running install_data
running install_egg_info
Removing /Applications/sage/local/lib/python2.5/site-packages/
Tkinter-1.0-py2.5.egg-info
Writing /Applications/sage/local/lib/python2.5/site-packages/
Tkinter-1.0-py2.5.egg-info
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ sage -c
"import Tkinter"
Traceback (most recent call last):
File "/Applications/sage/local/bin/sage-eval", line 14, in <module>
eval(compile(s,'<cmdline>','exec'))
File "<cmdline>", line 1, in <module>
File "/Applications/sage/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: dlopen(/Applications/sage/local/lib/python2.5/site-
packages/_tkinter.so, 2): Symbol not found: _Tk_GetNumMainWindows
Referenced from: /Applications/sage/local/lib/python2.5/site-
packages/_tkinter.so
Expected in: dynamic lookup


so it looks like tcl/tk 8.4 is not 64 bit by default?

Adam

Christian Nassau

unread,
Jun 1, 2009, 1:29:58 PM6/1/09
to sage-s...@googlegroups.com
Very strange... I wonder why you have an "-m64" in your gcc's? My
compilation statements look like this:

> building '_tkinter' extension
> gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers/ -I/Users/dummy/sage/local/include/python2.5 -c _tkinter.c -o build/temp.macosx-10.3-i386-2.5/_tkinter.o
> gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers/ -I/Users/dummy/sage/local/include/python2.5 -c tkappinit.c -o build/temp.macosx-10.3-i386-2.5/tkappinit.o
> gcc -L/Users/was/build/sage-3.4.2/local/lib -bundle -undefined dynamic_lookup build/temp.macosx-10.3-i386-2.5/_tkinter.o build/temp.macosx-10.3-i386-2.5/tkappinit.o -L/usr/lib -ltcl8.4 -ltk8.4 -o build/lib.macosx-10.3-i386-2.5/_tkinter.so
> running install_lib
> copying build/lib.macosx-10.3-i386-2.5/_tkinter.so -> /Users/dummy/sage/local/lib/python2.5/site-packages

Maybe you could try to run the 3 gcc invocations manually without the
"-m64"? What are your CC and CFLAGS environment variables?

Puzzled,
C.

Adam

unread,
Jun 1, 2009, 1:38:12 PM6/1/09
to sage-support
So perhaps there's something fundamentally wrong with my system
setup? That wouldn't surprise me....

eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ echo $CC
gcc
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ echo
$CFLAGS

eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$


eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ gcc -fno-
strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -
DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -I/
Library/Frameworks/Tcl.framework/Headers -I/Applications/sage/local/
include/python2.5 -c _tkinter.c -o build/temp.macosx-10.3-i386-2.5/
_tkinter.o
In file included from /Applications/sage/local/include/python2.5/
Python.h:57,
from _tkinter.c:25:
/Applications/sage/local/include/python2.5/pyport.h:761:2: error:
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc
config?)."


Does that help anything? I suppose that's why I have a -m64...

Adam

Christian Nassau

unread,
Jun 1, 2009, 1:52:44 PM6/1/09
to sage-s...@googlegroups.com
Adam wrote:
> /Applications/sage/local/include/python2.5/pyport.h:761:2: error:
> #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc
> config?)."

Ok, so the "-m64" was probably right... What does the "file" command say
about the architecture of your files? I'm getting this:

> christian-nassaus-mac-mini:~ dummy$ file sage/local/bin/python
> sage/local/bin/python: Mach-O executable i386
> christian-nassaus-mac-mini:~ dummy$ file /usr/lib/libtcl8.4.dylib
> /usr/lib/libtcl8.4.dylib: Mach-O universal binary with 4 architectures
> /usr/lib/libtcl8.4.dylib (for architecture ppc7400): Mach-O dynamically linked shared library ppc
> /usr/lib/libtcl8.4.dylib (for architecture ppc64): Mach-O 64-bit dynamically linked shared library ppc64
> /usr/lib/libtcl8.4.dylib (for architecture i386): Mach-O dynamically linked shared library i386
> /usr/lib/libtcl8.4.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64

I wonder whether your /usr/local/lib/libtcl8.5.dylib is somehow not
compatible with sage's sage/local/bin/python ... ?

C.

Adam

unread,
Jun 1, 2009, 1:58:42 PM6/1/09
to sage-support
Looks like you nailed that one....

eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ file /
Applications/sage/local/bin/python
/Applications/sage/local/bin/python: Mach-O 64-bit executable x86_64
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ file /usr/
lib/libtcl8.4.dylib
/usr/lib/libtcl8.4.dylib: symbolic link to ../../System/Library/
Frameworks/Tcl.framework/Versions/8.4/Tcl
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ file /
System/Library/Frameworks/Tcl.framework/Versions/8.4/Tcl
/System/Library/Frameworks/Tcl.framework/Versions/8.4/Tcl: Mach-O
universal binary with 4 architectures
/System/Library/Frameworks/Tcl.framework/Versions/8.4/Tcl (for
architecture ppc7400): Mach-O dynamically linked shared library ppc
/System/Library/Frameworks/Tcl.framework/Versions/8.4/Tcl (for
architecture ppc64): Mach-O 64-bit dynamically linked shared
library ppc64
/System/Library/Frameworks/Tcl.framework/Versions/8.4/Tcl (for
architecture i386): Mach-O dynamically linked shared library i386
/System/Library/Frameworks/Tcl.framework/Versions/8.4/Tcl (for
architecture x86_64): Mach-O 64-bit dynamically linked shared
library x86_64
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ file /usr/
local/lib/libtcl8.5.dylib
/usr/local/lib/libtcl8.5.dylib: Mach-O dynamically linked shared
library i386

So I can try re-compiling tcl and hoping I get a 64bit compatible
version out of it (need to set some -archs keywords, I guess...) and
see if that gets me anywhere. But I'm a little bothered that the
default version looks like it SHOULD be compatible.

Adam

Christian Nassau

unread,
Jun 1, 2009, 2:07:52 PM6/1/09
to sage-s...@googlegroups.com
Adam wrote:
> So I can try re-compiling tcl and hoping I get a 64bit compatible
> version out of it (need to set some -archs keywords, I guess...) and

Tcl has an "-enable-64-bit" switch in its configure script, so that
might do the trick.

> see if that gets me anywhere. But I'm a little bothered that the
> default version looks like it SHOULD be compatible.

Indeed, looks like the default 8.4 on your system might be the better
choice: I would first try to change the paths from 8.5 to 8.4 in
setup.py and recompile again. If it works that should be easier than
recompiling Tcl/Tk from scratch.

Good luck,
C.


>
> Adam
> >
>

Adam

unread,
Jun 1, 2009, 2:16:25 PM6/1/09
to sage-support
Yeah, but I tried that... now I know why it didn't work:

eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ sage
setup_8.4.py install
running install
running build
running build_py
running build_ext
building '_tkinter' extension
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers/ -I/usr/
include/ -I/Applications/sage/local/include/python2.5 -c _tkinter.c -o
build/temp.macosx-10.3-i386-2.5/_tkinter.o
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/System/Library/Frameworks/Tcl.framework/Versions/8.4/Headers/ -I/usr/
include/ -I/Applications/sage/local/include/python2.5 -c tkappinit.c -
o build/temp.macosx-10.3-i386-2.5/tkappinit.o
gcc -m64 -L/Applications/sage/local/lib -bundle -undefined
dynamic_lookup build/temp.macosx-10.3-i386-2.5/_tkinter.o build/
temp.macosx-10.3-i386-2.5/tkappinit.o -L/usr/lib/ -ltcl8.4 -ltk8.4 -o
build/lib.macosx-10.3-i386-2.5/_tkinter.so
ld warning: in /usr/lib//libtk8.4.dylib, missing required architecture
x86_64 in file
running install_lib
copying build/lib.macosx-10.3-i386-2.5/_tkinter.so -> /Applications/
sage/local/lib/python2.5/site-packages
running install_data
running install_egg_info
Removing /Applications/sage/local/lib/python2.5/site-packages/
Tkinter-1.0-py2.5.egg-info
Writing /Applications/sage/local/lib/python2.5/site-packages/
Tkinter-1.0-py2.5.egg-info
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ file /usr/
lib/libtk8.4.dylib
/usr/lib/libtk8.4.dylib: symbolic link to ../../System/Library/
Frameworks/Tk.framework/Versions/8.4/Tk
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ file /
System/Library/Frameworks/Tk.framework/Versions/8.4/Tk
/System/Library/Frameworks/Tk.framework/Versions/8.4/Tk: Mach-O
universal binary with 2 architectures
/System/Library/Frameworks/Tk.framework/Versions/8.4/Tk (for
architecture i386): Mach-O dynamically linked shared library
i386
/System/Library/Frameworks/Tk.framework/Versions/8.4/Tk (for
architecture ppc7400): Mach-O dynamically linked shared library
ppc
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$


So the default tcl has x86-64 but the default tk does not. So my best
guess is that I do not have to compile tcl from scratch, but I do have
to compile tk.... and in case you're wondering I haven't been able to
do that: http://www.nabble.com/Error-compiling-tk-8.5.7-on-Mac-OS-X-10.5-td23790967.html

I think this means I'm stuck, unless you have any other tips. But
either way, you've been a huge help, so thanks again!
Adam

Christian Nassau

unread,
Jun 1, 2009, 2:56:26 PM6/1/09
to sage-s...@googlegroups.com
Adam wrote:
> So the default tcl has x86-64 but the default tk does not. So my best
> guess is that I do not have to compile tcl from scratch, but I do have
> to compile tk.... and in case you're wondering I haven't been able to
> do that: http://www.nabble.com/Error-compiling-tk-8.5.7-on-Mac-OS-X-10.5-td23790967.html

I think you should specify a --with-tcl=<path-to-dir-with-tclConfig.sh>
when you build Tk. On my system I have

/Library/Frameworks/Tcl.framework/Versions/8.5/tclConfig.sh

so I'd try

./configure --enable-framework --disable-xft
--with-tcl=/Library/Frameworks/Tcl.framework/Versions/8.5

and see if that picks up the right Tcl header.

Gee, this is really painful... ;-)

Cheers,
C.

Adam

unread,
Jun 1, 2009, 5:30:41 PM6/1/09
to sage-support
Thanks. I finally got the tcl/tk issues worked out, so I now have tcl/
tk 8.5 with x86_64 support installed.

eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ file /
Library/Frameworks/Tk.framework/Versions/8.5/Tk
/Library/Frameworks/Tk.framework/Versions/8.5/Tk: Mach-O universal
binary with 3 architectures
/Library/Frameworks/Tk.framework/Versions/8.5/Tk (for architecture
ppc7400): Mach-O dynamically linked shared library ppc
/Library/Frameworks/Tk.framework/Versions/8.5/Tk (for architecture
i386): Mach-O dynamically linked shared library i386
/Library/Frameworks/Tk.framework/Versions/8.5/Tk (for architecture
x86_64): Mach-O 64-bit dynamically linked shared library x86_64
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ file /
Library/Frameworks/Tcl.framework/Versions/Current/Tcl
/Library/Frameworks/Tcl.framework/Versions/Current/Tcl: Mach-O
universal binary with 3 architectures
/Library/Frameworks/Tcl.framework/Versions/Current/Tcl (for
architecture ppc7400): Mach-O dynamically linked shared library
ppc
/Library/Frameworks/Tcl.framework/Versions/Current/Tcl (for
architecture i386): Mach-O dynamically linked shared library i386
/Library/Frameworks/Tcl.framework/Versions/Current/Tcl (for
architecture x86_64): Mach-O 64-bit dynamically linked shared
library x86_64

However, as you might expect, there's another problem:
eta /Applications/sage/spkg/optional/yacop1.0/Tkynter-1.0$ sage
setup_8.5.py install
running install
running build
running build_py
creating build
creating build/lib.macosx-10.3-i386-2.5
creating build/lib.macosx-10.3-i386-2.5/lib-tk
copying lib-tk/Tkinter.py -> build/lib.macosx-10.3-i386-2.5/lib-tk
running build_ext
building '_tkinter' extension
creating build/temp.macosx-10.3-i386-2.5
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/Library/Frameworks/Tcl.framework/Headers -I/Applications/sage/local/
include/python2.5 -c _tkinter.c -o build/temp.macosx-10.3-i386-2.5/
_tkinter.o
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-
madd -DNDEBUG -g -O3 -m64 -Wall -Wstrict-prototypes -DWITH_APPINIT=1 -
I/Library/Frameworks/Tcl.framework/Headers -I/Applications/sage/local/
include/python2.5 -c tkappinit.c -o build/temp.macosx-10.3-i386-2.5/
tkappinit.o
gcc -m64 -L/Applications/sage/local/lib -bundle -undefined
dynamic_lookup build/temp.macosx-10.3-i386-2.5/_tkinter.o build/
temp.macosx-10.3-i386-2.5/tkappinit.o -L/usr/lib/ -ltcl8.5 -ltk8.5 -o
build/lib.macosx-10.3-i386-2.5/_tkinter.so
ld warning: in /usr/local/lib/libtcl8.5.dylib, file is not of required
architecture
ld warning: in /usr/local/lib/libtk8.5.dylib, file is not of required
architecture
running install_lib
copying build/lib.macosx-10.3-i386-2.5/_tkinter.so -> /Applications/
sage/local/lib/python2.5/site-packages
running install_data
running install_egg_info
Removing /Applications/sage/local/lib/python2.5/site-packages/
Tkinter-1.0-py2.5.egg-info
Writing /Applications/sage/local/lib/python2.5/site-packages/
Tkinter-1.0-py2.5.egg-info


Apparently the libtcl and libtk .dylib files did not update. Should I
go back to the tcl/tk folks and ask them how to fix that problem?

Adam
Reply all
Reply to author
Forward
0 new messages