为scipy安装BLAS和LAPACK的最简单方法是什么?

时间:2015-10-27 12:40:17

标签: python numpy

我想运行一个别人准备的程序,它包括scipy。我试图用

安装scipy
pip install scipy

但它给了我一个很长的错误。我知道Anaconda和Canopy有各种各样的方法,但我认为这些方法很长。我想要一个简短的方法。我也试过

G:\determinator_Oskar>pip install scipy
Collecting scipy
  Using cached scipy-0.16.1.tar.gz
Building wheels for collected packages: scipy
  Running setup.py bdist_wheel for scipy
  Complete output from command g:\myve\scripts\python.exe -c "import setuptools;
__file__='e:\\temp_n~1\\pip-build-1xigxu\\scipy\\setup.py';exec(compile(open(__f
ile__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d e:\temp_
n~1\tmp07__zrpip-wheel-:
  lapack_opt_info:
  openblas_lapack_info:
    libraries openblas not found in ['g:\\myve\\lib', 'C:\\']
    NOT AVAILABLE

  lapack_mkl_info:
  mkl_info:
    libraries mkl,vml,guide not found in ['g:\\myve\\lib', 'C:\\']
    NOT AVAILABLE

    NOT AVAILABLE

  atlas_3_10_threads_info:
  Setting PTATLAS=ATLAS
    libraries tatlas,tatlas not found in g:\myve\lib
    libraries lapack_atlas not found in g:\myve\lib
    libraries tatlas,tatlas not found in C:\
    libraries lapack_atlas not found in C:\
  <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
    NOT AVAILABLE

  atlas_3_10_info:
    libraries satlas,satlas not found in g:\myve\lib
    libraries lapack_atlas not found in g:\myve\lib
    libraries satlas,satlas not found in C:\
    libraries lapack_atlas not found in C:\
  <class 'numpy.distutils.system_info.atlas_3_10_info'>
    NOT AVAILABLE

  atlas_threads_info:
  Setting PTATLAS=ATLAS
    libraries ptf77blas,ptcblas,atlas not found in g:\myve\lib
    libraries lapack_atlas not found in g:\myve\lib
    libraries ptf77blas,ptcblas,atlas not found in C:\
    libraries lapack_atlas not found in C:\
  <class 'numpy.distutils.system_info.atlas_threads_info'>
    NOT AVAILABLE

  atlas_info:
    libraries f77blas,cblas,atlas not found in g:\myve\lib
    libraries lapack_atlas not found in g:\myve\lib
    libraries f77blas,cblas,atlas not found in C:\
    libraries lapack_atlas not found in C:\
  <class 'numpy.distutils.system_info.atlas_info'>
    NOT AVAILABLE

  lapack_info:
    libraries lapack not found in ['g:\\myve\\lib', 'C:\\']
    NOT AVAILABLE

  lapack_src_info:
    NOT AVAILABLE

    NOT AVAILABLE

  g:\myve\lib\site-packages\numpy\distutils\system_info.py:1552: 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.
    warnings.warn(AtlasNotFoundError.__doc__)
  g:\myve\lib\site-packages\numpy\distutils\system_info.py:1563: UserWarning:
      Lapack (http://www.netlib.org/lapack/) libraries not found.
      Directories to search for the libraries can be specified in the
      numpy/distutils/site.cfg file (section [lapack]) or by setting
      the LAPACK environment variable.
    warnings.warn(LapackNotFoundError.__doc__)
  g:\myve\lib\site-packages\numpy\distutils\system_info.py:1566: UserWarning:
      Lapack (http://www.netlib.org/lapack/) sources not found.
      Directories to search for the sources can be specified in the
      numpy/distutils/site.cfg file (section [lapack_src]) or by setting
      the LAPACK_SRC environment variable.
    warnings.warn(LapackSrcNotFoundError.__doc__)
  Running from scipy source directory.
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 253, in <module>
      setup_package()
    File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 250, in setup_packa
ge
      setup(**metadata)
    File "g:\myve\lib\site-packages\numpy\distutils\core.py", line 135, in setup

      config = configuration()
    File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 175, in configurati
on
      config.add_subpackage('scipy')
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 1001, in
 add_subpackage
      caller_level = 2)
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 970, in
get_subpackage
      caller_level = caller_level + 1)
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 907, in
_get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "scipy\setup.py", line 15, in configuration
      config.add_subpackage('linalg')
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 1001, in
 add_subpackage
      caller_level = 2)
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 970, in
get_subpackage
      caller_level = caller_level + 1)
    File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 907, in
_get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "scipy\linalg\setup.py", line 20, in configuration
      raise NotFoundError('no lapack/blas resources found')
  numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

  ----------------------------------------
  Failed building wheel for scipy
Failed to build scipy
Installing collected packages: scipy
  Running setup.py install for scipy
    Complete output from command g:\myve\scripts\python.exe -c "import setuptool
s, tokenize;__file__='e:\\temp_n~1\\pip-build-1xigxu\\scipy\\setup.py';exec(comp
ile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __fi
le__, 'exec'))" install --record e:\temp_n~1\pip-3hncqr-record\install-record.tx
t --single-version-externally-managed --compile --install-headers g:\myve\includ
e\site\python2.7\scipy:
    lapack_opt_info:
    openblas_lapack_info:
      libraries openblas not found in ['g:\\myve\\lib', 'C:\\']
      NOT AVAILABLE

    lapack_mkl_info:
    mkl_info:
      libraries mkl,vml,guide not found in ['g:\\myve\\lib', 'C:\\']
      NOT AVAILABLE

      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas,tatlas not found in g:\myve\lib
      libraries lapack_atlas not found in g:\myve\lib
      libraries tatlas,tatlas not found in C:\
      libraries lapack_atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE

    atlas_3_10_info:
      libraries satlas,satlas not found in g:\myve\lib
      libraries lapack_atlas not found in g:\myve\lib
      libraries satlas,satlas not found in C:\
      libraries lapack_atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in g:\myve\lib
      libraries lapack_atlas not found in g:\myve\lib
      libraries ptf77blas,ptcblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE

    atlas_info:
      libraries f77blas,cblas,atlas not found in g:\myve\lib
      libraries lapack_atlas not found in g:\myve\lib
      libraries f77blas,cblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE

    lapack_info:
      libraries lapack not found in ['g:\\myve\\lib', 'C:\\']
      NOT AVAILABLE

    lapack_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    g:\myve\lib\site-packages\numpy\distutils\system_info.py:1552: 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.
      warnings.warn(AtlasNotFoundError.__doc__)
    g:\myve\lib\site-packages\numpy\distutils\system_info.py:1563: UserWarning:
        Lapack (http://www.netlib.org/lapack/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [lapack]) or by setting
        the LAPACK environment variable.
      warnings.warn(LapackNotFoundError.__doc__)
    g:\myve\lib\site-packages\numpy\distutils\system_info.py:1566: UserWarning:
        Lapack (http://www.netlib.org/lapack/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [lapack_src]) or by setting
        the LAPACK_SRC environment variable.
      warnings.warn(LapackSrcNotFoundError.__doc__)
    Running from scipy source directory.
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 253, in <module>
        setup_package()
      File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 250, in setup_pac
kage
        setup(**metadata)
      File "g:\myve\lib\site-packages\numpy\distutils\core.py", line 135, in set
up
        config = configuration()
      File "e:\temp_n~1\pip-build-1xigxu\scipy\setup.py", line 175, in configura
tion
        config.add_subpackage('scipy')
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 1001,
in add_subpackage
        caller_level = 2)
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 970, i
n get_subpackage
        caller_level = caller_level + 1)
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 907, i
n _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "scipy\setup.py", line 15, in configuration
        config.add_subpackage('linalg')
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 1001,
in add_subpackage
        caller_level = 2)
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 970, i
n get_subpackage
        caller_level = caller_level + 1)
      File "g:\myve\lib\site-packages\numpy\distutils\misc_util.py", line 907, i
n _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "scipy\linalg\setup.py", line 20, in configuration
        raise NotFoundError('no lapack/blas resources found')
    numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

    ----------------------------------------
Command "g:\myve\scripts\python.exe -c "import setuptools, tokenize;__file__='e:
\\temp_n~1\\pip-build-1xigxu\\scipy\\setup.py';exec(compile(getattr(tokenize, 'o
pen', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install
--record e:\temp_n~1\pip-3hncqr-record\install-record.txt --single-version-exter
nally-managed --compile --install-headers g:\myve\include\site\python2.7\scipy"
failed with error code 1 in e:\temp_n~1\pip-build-1xigxu\scipy      

我也试过

pip install lapack

有了这个结果

Collecting lapack
  Could not find a version that satisfies the requirement lapack (from versions
 )
No matching distribution found for lapack

我也试过

pip install blas

有类似的结果

G:\determinator_Oskar>pip install blas
Collecting blas
  Could not find a version that satisfies the requirement blas (from versions: )

No matching distribution found for blas

为什么scipy变得如此复杂?

11 个答案:

答案 0 :(得分:28)

SciPy installation page已经推荐了几种已经包含SciPy安装python的方法,例如WinPython

另一种方法是使用wheels(内置包格式):

pip install SomePackage-1.0-py2.py3-none-any.whl

您可以在http://www.lfd.uci.edu/~gohlke/pythonlibs/

找到的轮组

对于SciPy,您需要:

答案 1 :(得分:23)

  

“为什么scipy变得如此复杂?”

它变得如此复杂,因为Python的包管理系统是为跟踪Python包依赖而构建的,而SciPy和其他科学工具都具有Python以外的依赖关系。 Wheels解决了部分问题,但我的经验是像pip / virtualenv这样的工具不足以安装和管理科学的Python堆栈。

如果您想要一种简单的方法来启动和运行SciPy,我强烈建议Anaconda distribution。它将为您提供Python中科学计算所需的一切。

如果您想要这样做的“简短方法”(我将其解释为“我不想安装大量发行版”),您可以尝试miniconda然后运行{{1} }。

答案 2 :(得分:14)

对于 Debian Jessie Stretch ,安装以下软件包可解决此问题:

sudo apt-get install libblas3 liblapack3 liblapack-dev libblas-dev

您的下一个问题很可能是一个缺少的Fortran编译器,请通过安装它来解决此问题:

sudo apt-get install gfortran

如果您对丢失的Python.h文件有任何问题,请执行以下操作:

  

Python.h:没有这样的文件或目录

然后看一下这篇文章:https://stackoverflow.com/a/21530768/209532

答案 3 :(得分:4)

使用conda install scipy而不是pip解决了我的问题!

答案 4 :(得分:2)

对于Windows:最好使用此站点提供的预编译包: http://www.lfd.uci.edu/%7Egohlke/pythonlibs/#scipy

答案 5 :(得分:0)

为了完整性,虽然这可能不适合您的特定设置(外部程序+ Windows),但也可以在(大)SageMath下载中获得Scipy无忧。

答案 6 :(得分:0)

使用SciPy whl,下载相应的版本并运行pip install <whl_file>

OR

通读SciPy Windows issue and run one of the methods

OR

使用Miniconda

此外,请安装Visual C++ compiler for python2.7,以便提出要求。

答案 7 :(得分:0)

我在freeBSD上遇到了这个问题。 看来lapack软件包不见了,我解决了使用以下命令(以root用户身份)安装它们的问题:

pkg install lapack
pkg install atlas-devel  #not sure this is needed, but just in case

我想它也可以使用适当的软件包安装程序(例如apt-get)在其他系统上工作

答案 8 :(得分:0)

pip install Cython

之前

pip install sklearn

是我的把戏。

答案 9 :(得分:0)

始终适用于Ubuntu / Debian,chjortlund's answer很好,但并不完美,因为这样您可以获得未优化的BLAS库。您只需要做:

sudo apt install libatlas-base-dev

瞧瞧!

Source

答案 10 :(得分:0)

conda install liblapack

这对我有用