scipy给出了未定义的符号:clapack_sgesv

时间:2013-01-15 20:08:56

标签: python numpy compiler-errors scipy lapack

我希望有一个干净的开始,所以我编写了自己的 最新的ATLAS,Lapack和Python 2.7.3的副本。

我安装了numpy并从ATLAS识别出BLAS 和以下工作...

  python
  import numpy
  numpy.test()

但是scipy并不那么容易!

$ python
Python 2.7.3 (default, Jan 14 2013, 13:13:35)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy.linalg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/__init__.py", line 133, in <module>
    from basic import *
  File "/projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/basic.py", line 12, in <module>
    from lapack import get_lapack_funcs
  File "/projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/lapack.py", line 15, in <module>
    from scipy.linalg import clapack
ImportError: /projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/clapack.so: undefined symbol:
+clapack_sgesv

$ which python
/projects/nrel/cid/ladab/pkgi/bin/python

$ ldd /projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg/clapack.so
        linux-vdso.so.1 =>  (0x00007fff57bff000)
        libgfortran.so.3 => /usr/lib64/libgfortran.so.3 (0x00007f9229192000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f9228ef4000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f9228cde000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f922894b000)
        /lib64/ld-linux-x86-64.so.2 (0x000000387dc00000)

$ cat scipy-0.11.0/site.cfg
[DEFAULT]
library_dirs = /projects/nrel/cid/ladab/pkgi/lib
include_dirs = /projects/nrel/cid/ladab/pkgi/include
[blas_opt]
libraries = f77blas, cblas, atlas
[lapack_opt]
libraries = lapack, f77blas, cblas, atlas

$ env | egrep python
PYTHONPATH=/projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages

搜索clapack_sgesv的定义,我在site-packages / scipy中找不到:

$ cd /projects/nrel/cid/ladab/pkgi/lib/python2.7/site-packages/scipy/linalg

$ for ii in *.so; do echo ========== $ii; nm $ii | egrep clapack_sgesv
> done
========== atlas_version.so
========== calc_lwork.so
========== cblas.so
========== clapack.so
                 U clapack_sgesv
00000000002103e0 d doc_f2py_rout_clapack_sgesv
0000000000009810 t f2py_rout_clapack_sgesv
========== fblas.so
========== flapack.so
========== _flinalg.so

显然在LD_LIBRARY_PATH可用,但是scipy 没有使用它......

$ echo $LD_LIBRARY_PATH
/projects/nrel/cid/ladab/pkgi/lib:/usr/lib64

$ cd /projects/nrel/cid/ladab/pkgi/lib

$ for ii in *.so; do echo ========== $ii; nm $ii | egrep clapack_sgesv; done
========== libsatlas.so
0000000000094ce0 T clapack_sgesv
========== libtatlas.so
00000000000accb0 T clapack_sgesv

你有什么建议吗?

2 个答案:

答案 0 :(得分:1)

非常感谢Adam Cadien的评论...... http://www.scipy.org/Installing_SciPy/Linux中关于“在Ubuntu上使用gfortran构建所有内容(2010年11月)”的部分仍然运作良好。

答案 1 :(得分:0)

从Ubuntu 12.04升级到12.10之后我遇到了这个问题。问题是我在/usr/local/lib/python2.7/dist-packages中安装了两个版本的scipy。为了解决我所做的问题:

 sudo apt-get remove python-scipy
 sudo rm -fr /usr/local/lib/python2.7/dist-packages/scipy*
 sudo apt-get install python-scipy