Installation problem "cannot find -ltk" Suse 9.1

Hi,

I have two questions, I'll ask the simple one first. I migrated from Matlab
to Octave which uses gnuplot and thus provides 3D plotting capability, which
is adequate. Matplotlib is 2D, are there any good 3D plotters out there for
python?

Second question: I can't install Matplotlib and maybe someone will have seen
the symptom before or have some bright ideas to help me figure it out. I'm
running SuSE 9.1, python 2.3.3, and seem to have Tcl/Tk/Tkinter installed OK.
For example:

#!/usr/bin/env python

from Tkinter import *
root = Tk()
w = Label(root, text="Hello, world!")
w.pack()
root.mainloop()

does the right thing by bringing up a window with the text.

$PYTHONHOME = /usr

I set BUILD_GTKAGG = 0 in setup.py. In an xterm as root I ran this and the
output follows

\start

# python setup.py build
Xlib: connection to ":0.0" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key
Using default library and include directories for Tcl and Tk because a
Tk window failed to open. You may need to define DISPLAY for Tk to work
so that setup can determine where your libraries are located.
running build
running build_py
creating build
creating build/lib.linux-i686-2.3
copying lib/pylab.py -> build/lib.linux-i686-2.3
creating build/lib.linux-i686-2.3/matplotlib
copying lib/matplotlib/patches.py -> build/lib.linux-i686-2.3/matplotlib
copying lib/matplotlib/_image.py -> build/lib.linux-i686-2.3/matplotlib

... etc copying a bunch of files into the build directory

copying lib/pytz/zoneinfo/Africa/Tripoli.py ->
build/lib.linux-i686-2.3/pytz/zoneinfo/Africa
copying lib/pytz/zoneinfo/Africa/Banjul.py ->
build/lib.linux-i686-2.3/pytz/zoneinfo/Africa
running build_ext
building 'matplotlib._nc_transforms' extension
creating build/temp.linux-i686-2.3
creating build/temp.linux-i686-2.3/src
creating build/temp.linux-i686-2.3/CXX
gcc -pthread -fno-strict-aliasing -DNDEBUG -D_FILE_OFFSET_BITS=64
-DHAVE_LARGEFILE_SUPPORT -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall
-fPIC -Isrc -I. -I/usr/include/python2.3 -c CXX/IndirectPythonInterface.cxx
-o build/temp.linux-i686-2.3/CXX/IndirectPythonInterface.o -DNUMERIC=1
gcc -pthread -fno-strict-aliasing -DNDEBUG -D_FILE_OFFSET_BITS=64
-DHAVE_LARGEFILE_SUPPORT -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall
-fPIC -Isrc -I. -I/usr/include/python2.3 -c CXX/cxxsupport.cxx -o
build/temp.linux-i686-2.3/CXX/cxxsupport.o -DNUMERIC=1
gcc -pthread -fno-strict-aliasing -DNDEBUG -D_FILE_OFFSET_BITS=64
-DHAVE_LARGEFILE_SUPPORT -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall
-fPIC -Isrc -I. -I/usr/include/python2.3 -c src/_nc_transforms.cpp -o
build/temp.linux-i686-2.3/src/_nc_transforms.o -DNUMERIC=1
In file included from /usr/include/python2.3/Python.h:8,
                 from CXX/Objects.hxx:9,
                 from CXX/Extensions.hxx:18,
                 from src/_transforms.h:12,
                 from src/_nc_transforms.cpp:2:
/usr/include/python2.3/pyconfig.h:847:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/g++/i586-suse-linux/bits/os_defines.h:39,
                 from /usr/include/g++/i586-suse-linux/bits/c++config.h:35,
                 from /usr/include/g++/functional:53,
                 from src/_nc_transforms.cpp:1:
/usr/include/features.h:131:1: warning: this is the location of the previous
definition
gcc -pthread -fno-strict-aliasing -DNDEBUG -D_FILE_OFFSET_BITS=64
-DHAVE_LARGEFILE_SUPPORT -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall
-fPIC -Isrc -I. -I/usr/include/python2.3 -c CXX/cxxextensions.c -o
build/temp.linux-i686-2.3/CXX/cxxextensions.o -DNUMERIC=1
gcc -pthread -fno-strict-aliasing -DNDEBUG -D_FILE_OFFSET_BITS=64
-DHAVE_LARGEFILE_SUPPORT -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall
-fPIC -Isrc -I. -I/usr/include/python2.3 -c src/mplutils.cpp -o
build/temp.linux-i686-2.3/src/mplutils.o -DNUMERIC=1
gcc -pthread -fno-strict-aliasing -DNDEBUG -D_FILE_OFFSET_BITS=64
-DHAVE_LARGEFILE_SUPPORT -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall
-fPIC -Isrc -I. -I/usr/include/python2.3 -c CXX/cxx_extensions.cxx -o
build/temp.linux-i686-2.3/CXX/cxx_extensions.o -DNUMERIC=1
g++ -pthread -shared build/temp.linux-i686-2.3/src/_nc_transforms.o
build/temp.linux-i686-2.3/src/mplutils.o
build/temp.linux-i686-2.3/CXX/cxx_extensions.o
build/temp.linux-i686-2.3/CXX/cxxsupport.o
build/temp.linux-i686-2.3/CXX/IndirectPythonInterface.o
build/temp.linux-i686-2.3/CXX/cxxextensions.o -lstdc++ -lm -o
build/lib.linux-i686-2.3/matplotlib/_nc_transforms.so
building 'matplotlib.backends._tkagg' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -D_FILE_OFFSET_BITS=64
-DHAVE_LARGEFILE_SUPPORT -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall
-fPIC -I/usr/local/include -I/usr/local/include -I/usr/local/include
-I/usr/include -Isrc -Iagg22/include -I. -I/usr/local/include -I/usr/include
-I/usr/local/include/freetype2 -I/usr/local/include/freetype2
-I/usr/local/include/freetype2 -I/usr/include/freetype2 -Isrc/freetype2
-Iagg22/include/freetype2 -I./freetype2 -I/usr/local/include/freetype2
-I/usr/include/freetype2 -I/usr/include/python2.3 -c src/_tkagg.cpp -o
build/temp.linux-i686-2.3/src/_tkagg.o
g++ -pthread -shared build/temp.linux-i686-2.3/src/_tkagg.o -L/usr/local/lib
-L/usr/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/lib -L/usr/lib -ltk
-ltcl -lpng -lz -lstdc++ -lm -lfreetype -lz -lstdc++ -lm -o
build/lib.linux-i686-2.3/matplotlib/backends/_tkagg.so
/linux1/usr/bin/../lib/gcc-lib/i586-suse-linux/3.3.3/../../../../i586-suse-linux/bin/ld:
cannot find -ltk
collect2: ld returned 1 exit status
error: command 'g++' failed with exit status 1

\end

I'm figuring the "Tk window open failed" bit at the start is just because it
seems to take a few seconds for Tk windows to appear on my system, and its
not coded to wait. So assuming that's not fatal, it seems the problem boils
down to "cannot find -ltk". I have searched for a few hours on google to no
avail. The only things I can suspect are maybe:

- I might be missing some installed components for development stuff in Tcl or
g++?
- Maybe need to have some environment variables set (e.g. for Tk?)
- Have some sort of path mismatch where it's looking for something that is
somewhere else?

I've compiled a few things successfully on this set up now and not come across
this one, any thoughts appreciated.

Cheers
Jason

Second question: I can't install Matplotlib and maybe someone will have seen
the symptom before or have some bright ideas to help me figure it out. I'm
running SuSE 9.1, python 2.3.3, and seem to have Tcl/Tk/Tkinter installed OK.

I set BUILD_GTKAGG = 0 in setup.py. In an xterm as root I ran this and the
output follows

\start

# python setup.py build
Xlib: connection to ":0.0" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key
Using default library and include directories for Tcl and Tk because a
Tk window failed to open. You may need to define DISPLAY for Tk to work
so that setup can determine where your libraries are located.
running build
running build_py
creating build
creating build/lib.linux-i686-2.3
copying lib/pylab.py -> build/lib.linux-i686-2.3
creating build/lib.linux-i686-2.3/matplotlib
copying lib/matplotlib/patches.py -> build/lib.linux-i686-2.3/matplotlib
copying lib/matplotlib/_image.py -> build/lib.linux-i686-2.3/matplotlib

... etc copying a bunch of files into the build directory

[mostly snipped]

g++ -pthread -shared build/temp.linux-i686-2.3/src/_tkagg.o -L/usr/local/lib
-L/usr/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/lib -L/usr/lib -ltk
-ltcl -lpng -lz -lstdc++ -lm -lfreetype -lz -lstdc++ -lm -o
build/lib.linux-i686-2.3/matplotlib/backends/_tkagg.so
/linux1/usr/bin/../lib/gcc-lib/i586-suse-linux/3.3.3/../../../../i586-suse-linux/bin/ld:
cannot find -ltk
collect2: ld returned 1 exit status
error: command 'g++' failed with exit status 1

\end

I'm figuring the "Tk window open failed" bit at the start is just because it
seems to take a few seconds for Tk windows to appear on my system, and its
not coded to wait.

That "Tk window open failed" problem looks to me like it may be *the*
problem. matplotlib opens a Tk window to help figure out where Tk is;
the fallback isn't working. In your case I think the Tk window failed
because "root" is trying to open a window on a display owned by your
non-priviledged account. Having the system say "no" to root about
anything is really counter intuitive to me, but I've experienced it
myself and it's discussed some here:

http://lists.debian.org/debian-user/1998/09/msg00113.html

The article suggests that if you do

% xhost +localhost

in your non-priviledged account before trying to build as root, X will
allow the Tk window open.

So assuming that's not fatal, it seems the problem boils
down to "cannot find -ltk". I have searched for a few hours on google to no
avail. The only things I can suspect are maybe:

- I might be missing some installed components for development stuff in Tcl or
g++?

Maybe. On my RHEL3 system, I have tk-devel-8.3.5-92.2 installed.

Hope this helps,
Todd

···

On Fri, 2005-03-18 at 05:02, Jason Hoogland wrote:

Todd,

Thanks, your suggestion prodded me in the right direction, a good old
permission issue. It's all working now. Am pasting my notes below.

Jason

I tried the remedies suggested here:
http://lists.debian.org/debian-user/1998/09/msg00113.html
(xhost +localhost) and here:
http://lists.debian.org/debian-user/1998/08/msg03179.html
(use ssh which takes care of the $DISPLAY enviro variable)

In the second I no longer got the two lines at the top of the build output:
Xlib: connection to ":0.0" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key

But everything else went exactly the same. So then I decided to:

# chmod -R a+rwx *

within the untarred Matplotlib installation root (/matplotlib-0.72.1), to open
up the permissions. After again setting BUILD_GTKAGG=0 in setup.py I then
ran:

python setup.py build

as my normal (non-root) user and it went perfectly. Since my python
installation is in /usr/lib/python which requires root privileges to create
directories etc, I then su'd and from the same directory:

# python setup.py install

and it transferred the files etc. as desired to the python installation. I
then had to change /usr/share/matplotlib/.matplotlibrc:

\snip
#### CONFIGURATION BEGINS HERE
backend : GTKAgg # the default backend
numerix : Numeric # Numeric or numarray
interactive : False # see
http://matplotlib.sourceforge.net/interactive.html
toolbar : toolbar2 # None | classic | toolbar2
timezone : UTC # a pytz timezone string, eg US/Central or
Europe/Paris
\snip

so that the backend was set to 'TKAgg' and interactive set to 'True'. It
didn't like 'TKAgg', it needs 'TkAgg'. I confirmed operation with:

from pylab import *
plot([1,2,3])
[<matplotlib.lines.Line2D instance at 0x40479a2c>]

and the Tk window comes up and is zoomable etc. Looks good, looks like the
effort might be worth it!

···

On Saturday 19 March 2005 00:23, Todd Miller wrote:

On Fri, 2005-03-18 at 05:02, Jason Hoogland wrote:
> Second question: I can't install Matplotlib and maybe someone will have
> seen the symptom before or have some bright ideas to help me figure it
> out. I'm running SuSE 9.1, python 2.3.3, and seem to have Tcl/Tk/Tkinter
> installed OK.
>
> I set BUILD_GTKAGG = 0 in setup.py. In an xterm as root I ran this and
> the output follows
>
> \start
>
> # python setup.py build
> Xlib: connection to ":0.0" refused by server
> Xlib: Invalid MIT-MAGIC-COOKIE-1 key
> Using default library and include directories for Tcl and Tk because a
> Tk window failed to open. You may need to define DISPLAY for Tk to work
> so that setup can determine where your libraries are located.
> running build
> running build_py
> creating build
> creating build/lib.linux-i686-2.3
> copying lib/pylab.py -> build/lib.linux-i686-2.3
> creating build/lib.linux-i686-2.3/matplotlib
> copying lib/matplotlib/patches.py -> build/lib.linux-i686-2.3/matplotlib
> copying lib/matplotlib/_image.py -> build/lib.linux-i686-2.3/matplotlib
>
> ... etc copying a bunch of files into the build directory

[mostly snipped]

> g++ -pthread -shared build/temp.linux-i686-2.3/src/_tkagg.o
> -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/lib
> -L/usr/local/lib -L/usr/lib -ltk -ltcl -lpng -lz -lstdc++ -lm -lfreetype
> -lz -lstdc++ -lm -o
> build/lib.linux-i686-2.3/matplotlib/backends/_tkagg.so
> /linux1/usr/bin/../lib/gcc-lib/i586-suse-linux/3.3.3/../../../../i586-sus
>e-linux/bin/ld: cannot find -ltk
> collect2: ld returned 1 exit status
> error: command 'g++' failed with exit status 1
>
> \end
>
> I'm figuring the "Tk window open failed" bit at the start is just because
> it seems to take a few seconds for Tk windows to appear on my system, and
> its not coded to wait.

That "Tk window open failed" problem looks to me like it may be *the*
problem. matplotlib opens a Tk window to help figure out where Tk is;
the fallback isn't working. In your case I think the Tk window failed
because "root" is trying to open a window on a display owned by your
non-priviledged account. Having the system say "no" to root about
anything is really counter intuitive to me, but I've experienced it
myself and it's discussed some here:

Re: Xlib: Invalid MIT-MAGIC-COOKIE-1 key

The article suggests that if you do

% xhost +localhost

in your non-priviledged account before trying to build as root, X will
allow the Tk window open.

> So assuming that's not fatal, it seems the problem boils
> down to "cannot find -ltk". I have searched for a few hours on google to
> no avail. The only things I can suspect are maybe:
>
> - I might be missing some installed components for development stuff in
> Tcl or g++?

Maybe. On my RHEL3 system, I have tk-devel-8.3.5-92.2 installed.

Hope this helps,
Todd

--

Jason Hoogland hoogland@...536...
Doctoral student ph(w) +61 7 3365 4457
Centre for Hypersonics ph(mob) +61 413 300 887
The University of Queensland UTC+10
Brisbane QLD 4072, Australia http://www.marsgravity.org
----------------------------------------------------------