Building Numpy from source

This post should act as a note to future Rob, as well as a hint to anyone else that runs into this problem after building and installing numpy.

> ImportError: path_to_python/site-packages/numpy/linalg/lapack_lite.so:
>
undefined symbol: zgesdd_

I was motivated to build my own version of Numpy because I use a newer version of Python than the one that is provided on some of the machines I use in the lab.  I’ve built up my entire python ecosystem from source; and thus far, everything had worked out smoothly.  The real problem with this numpy error, is that it can happen for so many reasons, none of which was the reason it was occurring for me.

First, make sure that the build script is looking for BLAS and LAPACK in the right place.  If you download the actual numpy sources, this is fairly simple.  Just copy site.cfg.example to site.cfg in the top-level directory, and then make sure that the include and library path variables include the proper paths.  Now, the crux of the problem, which took me a few hours to resolve, is that blas and lapack must be built as shared libraries.  Numpy assumes this is the case and will look to link them at runtime.  I had previously built BLAS and LAPACK as static libraries, so numpy could not find them, and  hence failed with the error stated above.  Simply re-downloading lapack, altering the makefile to build shared libraries, and then installing them solved the problem.  Obviously, it’s always easiest if you have admin privileges on a machine and can handle these things with a decent package manger.  However, if you have to build sources by hand and run into this problem, I hope this note helps you out and saves you some time!

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please insert the signs in the image: