py-matplotlib build error

I am trying to install the port math/py-matplotlib and the build fails with the following error:
# make
Code:
===>   py27-matplotlib-1.0.1_3 depends on file: /usr/local/lib/python2.7/site-packages/numpy/core/numeric.py - found
===>   py27-matplotlib-1.0.1_3 depends on package: py27-dateutil>=1.4 - found
===>   py27-matplotlib-1.0.1_3 depends on package: py27-pytz>0 - found
===>   py27-matplotlib-1.0.1_3 depends on file: /usr/local/lib/python2.7/site-packages/_tkinter.so - found
===>   py27-matplotlib-1.0.1_3 depends on file: /usr/local/bin/python2.7 - found
===>   py27-matplotlib-1.0.1_3 depends on file: /usr/local/bin/intltool-extract - found
===>   py27-matplotlib-1.0.1_3 depends on executable: pkg-config - found
===>   py27-matplotlib-1.0.1_3 depends on executable: pygobject-codegen-2.0 - found
===>   py27-matplotlib-1.0.1_3 depends on file: /usr/local/libdata/pkgconfig/pygtk-2.0.pc - found
===>   py27-matplotlib-1.0.1_3 depends on shared library: freetype.9 - found
===>   py27-matplotlib-1.0.1_3 depends on shared library: png.6 - found
===>   py27-matplotlib-1.0.1_3 depends on shared library: atk-1.0.0 - found
===>   py27-matplotlib-1.0.1_3 depends on shared library: glib-2.0.0 - found
===>   py27-matplotlib-1.0.1_3 depends on shared library: gtk-x11-2.0.0 - found
===>   py27-matplotlib-1.0.1_3 depends on shared library: glade-2.0.0 - found
===>   py27-matplotlib-1.0.1_3 depends on shared library: xml2.5 - found
===>   py27-matplotlib-1.0.1_3 depends on shared library: pango-1.0.0 - found
===>  Configuring for py27-matplotlib-1.0.1_3
basedirlist is: ['/usr/local', '/usr']
============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.0.1
                python: 2.7.2 (default, Nov 13 2011, 04:06:00)  [GCC 4.2.1
                        20070719  [FreeBSD]]
              platform: freebsd8

REQUIRED DEPENDENCIES
                 numpy: no
                        * You must install numpy 1.1 or later to build
                        * matplotlib.
*** Error code 1

Stop in /usr/ports/math/py-matplotlib.
I tried the following:
1) Checked dependencies
# make build-depends-list
Code:
/usr/ports/accessibility/atk
/usr/ports/devel/glib20
/usr/ports/devel/libglade2
/usr/ports/devel/pkg-config
/usr/ports/devel/py-dateutil
/usr/ports/devel/py-gobject
/usr/ports/devel/py-pytz
/usr/ports/graphics/png
/usr/ports/lang/python27
/usr/ports/math/py-numpy <-----
/usr/ports/print/freetype2
/usr/ports/textproc/intltool
/usr/ports/textproc/libxml2
/usr/ports/x11-toolkits/gtk20
/usr/ports/x11-toolkits/pango
/usr/ports/x11-toolkits/py-gtk2
/usr/ports/x11-toolkits/py-tkinter
2) Checked whether py-numpy is installed
# ls /var/db/pkg | grep py27-numpy
Code:
py27-numpy-1.6.1,1
3) Reinstalled /usr/ports/x11-toolkits/py-gtk2 with 'numpy' support.
4) Tried to pin-point the problem in /usr/ports/math/py-matplotlib/work/matplotlib-1.0.1/setup.py script
# cd /usr/ports/math/py-matplotlib/work/matplotlib-1.0.1
# python setup.py

Code:
basedirlist is: ['/usr/local', '/usr']
============================================================================
BUILDING MATPLOTLIB
            matplotlib: 1.0.1
                python: 2.7.2 (default, Nov 13 2011, 04:06:00)  [GCC 4.2.1
                        20070719  [FreeBSD]]
              platform: freebsd8

REQUIRED DEPENDENCIES
                 numpy: no
                        * You must install numpy 1.1 or later to build
                        * matplotlib.
Don't know how to proceed further. Please help! BTW the ports tree is up-to-date.
 
I also checked whether python is able to import numpy or not
# python
Code:
Python 2.7.2 (default, Nov 13 2011, 04:06:00)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd8
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
    import add_newdocs
  File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 13, in <module>
    from polynomial import *
  File "/usr/local/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 17, in <module>
    from numpy.linalg import eigvals, lstsq
  File "/usr/local/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 48, in <module>
    from linalg import *
  File "/usr/local/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 23, in <module>
    from numpy.linalg import lapack_lite
ImportError: /usr/local/lib/libalapack.so.2: Undefined symbol "cblas_zswap"
 
% vi /usr/local/lib/python2.7/site-packages/numpy/distutils/site.cfg
Code:
[DEFAULT]
lapack_type=atlas
library_dirs = /usr/lib:/usr/local/lib:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd8.2/4.6.3/../../../
include_dirs = /usr/include:/usr/local/include:/usr/local/include/suitesparse
src_dirs = /usr/local/src
# search static libraries (.a) in preference to shared ones (.so)
search_static_first = 0
[atlas]
library_dirs = /usr/local/lib:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd8.2/4.6.3/../../../
atlas_libs = alapack, atlas <---------
Note that 'f77blas' and 'cblas' libraries are missing. Ideally the line should be (Check: /usr/ports/math/py-numpy/work/numpy-1.6.1/site.cfg.example):
Code:
atlas_libs = alapack, f77blas, cblas, atlas
Therefore, I tried to rebuild /usr/ports/math/py-numpy using
# make -DWITH_ATLAS
This option is ignored (by make) since it requires static ATLAS library; I had shared library installed instead. I had to rebuild (and reinstall) ATLAS (/usr/ports/math/atlas).
# make -DWITH_STATIC
# make deinstall && make reinstall && make clean
Then, rebuilt and reinstalled numpy (see above). Now /usr/local/lib/python2.7/site-packages/numpy/distutils/site.cfg has the correct ATLAS library affiliations. Subsequently, I reinstalled /usr/ports/math/py-numpy/py-gtk2. (Recall that py-gtk2 depends on py-numpy). Then,
# cd /usr/ports/math/py-matplotlib
# make install clean
It installs without any errors. Problem solved!
 
Back
Top