导入scipy.stats时的ImportError,未定义的符号(scipy版本0.14.0)

时间:2014-05-24 19:26:18

标签: python-2.7 scipy importerror python-import

我刚升级到Scipy 0.14.0和Ubuntu 14.04。现在当我尝试导入统计数据时,我得到一个ImportError。

import scipy.stats as stats

Traceback (most recent call last):
  File "/home/user1/Documents/test/importTest/importScipy.py", line 1, in <module>
    import scipy.stats as stats
  File "/usr/local/lib/python2.7/dist-packages/scipy/stats/__init__.py", line 334, in <module>
    from .stats import *
  File "/usr/local/lib/python2.7/dist-packages/scipy/stats/stats.py", line 181, in <module>
    import scipy.special as special
  File "/usr/local/lib/python2.7/dist-packages/scipy/special/__init__.py", line 548, in <module>
    from .basic import *
  File "/usr/local/lib/python2.7/dist-packages/scipy/special/basic.py", line 17, in <module>
    from . import orthogonal
  File "/usr/local/lib/python2.7/dist-packages/scipy/special/orthogonal.py", line 90, in <module>
    from scipy import linalg
  File "/usr/local/lib/python2.7/dist-packages/scipy/linalg/__init__.py", line 159, in <module>
    from .misc import *
  File "/usr/local/lib/python2.7/dist-packages/scipy/linalg/misc.py", line 5, in <module>
    from . import blas
  File "/usr/local/lib/python2.7/dist-packages/scipy/linalg/blas.py", line 145, in <module>
    from scipy.linalg import _fblas
ImportError: /usr/local/lib/python2.7/dist-packages/scipy/linalg/_fblas.so: undefined symbol: clange_

2 个答案:

答案 0 :(得分:0)

从源代码安装解决了这个问题。

首先下载numpy和scipy tarball。

然后在我的机器上找到BLAS和LAPACK * .so文件。我在/ usr / lib /中找到了它们。如果他们不在那里你可以安装它们。我使用标准的Ubuntu查找器来定位它们:

find -iname 'libblas.so'
find -iname 'liblapack.so'

所以我为安装设置了一些环境变量。

export BLAS=/usr/lib/libblas.so
export LAPACK=/usr/lib/liblapack.so

然后我下载了numpy和scipy的源代码tarball,解压缩了tarball,然后通过cd安装到安装目录中

python setup.py build
sudo python setup.py install

注意:您可能需要指定安装目录。

欢迎评论。也许有更好的方法。

答案 1 :(得分:0)

问题与Scipy缺少对LAPACK的正确引用有关。我按照@jtorca建议的说明进行操作,发现你甚至不需要通过tarball安装。对我来说,以下是诀窍:

apt-get install libopenblas-dev liblapack-dev
export BLAS=/usr/lib/libblas.so
export LAPACK=/usr/lib/liblapack.so
pip install numpy
pip install scipy