如何告诉Python Atlas的安装位置

4 投票
3 回答
2048 浏览
提问于 2025-04-17 20:26

我现在正在一台没有管理员权限的电脑上安装Python的scikit-learn包,使用的是Fedora 14系统,Python版本是2.7。

因为没有安装pip,所以我用的是easy_install来安装:

easy_install --prefix=$HOME/.local -U scikit-learn

在安装过程中,它提示我BLAS没有安装。我之前尝试过安装scipy,但在找到和安装Atlas/BLAS时遇到了麻烦。后来我检查了一下,发现numpy和Atlas没有问题:

>>> import numpy as np
>>> np.__config__.show()
atlas_threads_info:
    libraries = ['lapack', 'ptf77blas', 'ptcblas', 'atlas']
    library_dirs = ['/usr/lib/atlas']
    language = f77
    include_dirs = ['/usr/include']

blas_opt_info:
    libraries = ['ptf77blas', 'ptcblas', 'atlas']
    library_dirs = ['/usr/lib/atlas']
    define_macros = [('ATLAS_INFO', '"\\"3.8.3\\""')]
    language = c
    include_dirs = ['/usr/include']

atlas_blas_threads_info:
    libraries = ['ptf77blas', 'ptcblas', 'atlas']
    library_dirs = ['/usr/lib/atlas']
    language = c
    include_dirs = ['/usr/include']

lapack_opt_info:
    libraries = ['lapack', 'ptf77blas', 'ptcblas', 'atlas']
    library_dirs = ['/usr/lib/atlas']
    define_macros = [('ATLAS_INFO', '"\\"3.8.3\\""')]
    language = f77
    include_dirs = ['/usr/include']

lapack_mkl_info:
  NOT AVAILABLE

blas_mkl_info:
  NOT AVAILABLE

mkl_info:
  NOT AVAILABLE

/usr/lib/atlas这个文件夹是存在的,并且里面有一些.so文件。

这是easy_install停止的错误信息:

error: Setup script exited with error: Command "gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/lib/python2.7/site-packages/numpy/core/include -I/usr/lib/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c sklearn/__check_build/_check_build.c -o build/temp.linux-i686-2.7/sklearn/__check_build/_check_build.o" failed with exit status 1
/usr/lib/python2.7/site-packages/numpy/distutils/misc_util.py:248: RuntimeWarning: Parent module 'numpy.distutils' not found while handling absolute import
  from numpy.distutils import log

还有安装过程中早些时候的警告信息:

/usr/lib/python2.7/site-packages/numpy/distutils/system_info.py:1392: UserWarning:
    Atlas (http://math-atlas.sourceforge.net/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [atlas]) or by setting
    the ATLAS environment variable.

所以看起来安装过程找不到numpy或Atlas。我该怎么告诉它去哪里找这些东西呢?

3 个回答

0

从源代码安装numpy和scipy有时候会比较麻烦。如果你想要简单一点的方法,我建议你安装一个科学计算的Python版本,这样会自动安装一个带有所有必要库的Python。市面上有几个选择,我推荐你使用来自continuum.io的anaconda,你可以在这里下载

0

如果你没有管理员权限,但想要安装自己的模块,使用虚拟环境(virtualenv)是个不错的选择。

要设置一个默认的环境,只需执行以下命令:

$ pip install virtualenv
$ virtualenv ~/.default_env

# Add the activate script to the bashrc

$ echo "source ~/.default_env/bin/activate

之后,你就可以使用pip或者easy_install来安装你想要的任何软件包了。

0

我本来想在评论里问这个,但我的声望不够,所以只能在这里问:

在运行 easy_install 之前,先执行 export ATLAS=/usr/lib/atlas/libatlas.so 这个命令,有帮助吗?

撰写回答