Python 为 scipy 安装 BLAS 和 LAPACK 的最简单方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33368261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the easiest way to install BLAS and LAPACK for scipy?
提问by Marko
I would like to run a programme that someone else has prepared and it includes scipy. I have tried to install scipy with
我想运行一个别人已经准备好的程序,它包括 scipy。我试图安装 scipy
pip install scipy
but it gives me a long error. I know there are ways with Anaconda and Canopy but I think these are long ways. I would like to have a short way. I have also tried
但它给了我一个很长的错误。我知道 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
I have also tried
我也试过
pip install lapack
with this result
有了这个结果
Collecting lapack
Could not find a version that satisfies the requirement lapack (from versions
)
No matching distribution found for lapack
I have also tried
我也试过
pip install blas
with similar results
结果相似
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
Why does a scipy get so complicated ?
为什么 scipy 变得如此复杂?
采纳答案by agold
The SciPy installation pagealready recommends several ways of installing python with SciPy already included, such as WinPython.
该SciPy的安装页面已经建议已经包含SciPy的安装Python的几种方式,如WinPython。
Another way is to use wheels(a built-package format):
另一种方法是使用轮子(内置包格式):
pip install SomePackage-1.0-py2.py3-none-any.whl
The wheel packages you can find on: http://www.lfd.uci.edu/~gohlke/pythonlibs/
您可以在以下位置找到车轮包:http: //www.lfd.uci.edu/~gohlke/pythonlibs/
For SciPy you need:
对于 SciPy,您需要:
- the NumPy wheel packages
- and the SciPy wheel packages
回答by jakevdp
"Why does a scipy get so complicated?
“为什么 scipy 会变得如此复杂?
It gets so complicated because Python's package management system is built to track Python package dependencies, and SciPy and other scientific tools have dependencies beyond Python. Wheelsfix part of the problem, but my experience is that tools like pip
/virtualenv
are just not sufficient for installing and managing a scientific Python stack.
它变得如此复杂,因为 Python 的包管理系统是为跟踪 Python 包依赖关系而构建的,而 SciPy 和其他科学工具的依赖关系超出了 Python。Wheels解决了部分问题,但我的经验是像pip
/这样的工具virtualenv
不足以安装和管理科学的 Python 堆栈。
If you want an easy way to get up and running with SciPy, I would highly suggest the Anaconda distribution. It will give you everything you need for scientific computing in Python.
如果您想要一种简单的方法来启动和运行 SciPy,我强烈建议您使用Anaconda 发行版。它将为您提供在 Python 中进行科学计算所需的一切。
If you want a "short way" of doing this (I'm interpreting that as "I don't want to install a huge distribution"), you might try minicondaand then run conda install scipy
.
如果您想要一种“简短的方式”来执行此操作(我将其解释为“我不想安装一个巨大的发行版”),您可以尝试使用miniconda,然后运行conda install scipy
.
回答by Hmnshu
For windows: Best is to use pre-compiled package available from this site: http://www.lfd.uci.edu/%7Egohlke/pythonlibs/#scipy
对于 Windows:最好使用以下站点提供的预编译包:http: //www.lfd.uci.edu/%7Egohlke/pythonlibs/#scipy
回答by Bilal
Using conda install scipy instead of pip solved the problem for me!
使用 conda install scipy 而不是 pip 为我解决了这个问题!
回答by kcrisman
回答by Ani Menon
Either use SciPy whl, download the appropriate one and run pip install <whl_file>
要么使用SciPy whl,下载适当的一个并运行pip install <whl_file>
OR
或者
Read through SciPy Windows issue and run one of the methods.
OR
或者
Use Miniconda.
使用Miniconda。
Additionally, install Visual C++ compiler for python2.7in-case it asks for it.
此外,如果需要,请为 python2.7安装Visual C++ 编译器。
回答by chjortlund
For Debian Jessieand Stretchinstalling the following packages resolves the issue:
对于Debian Jessie和Stretch,安装以下软件包可解决此问题:
sudo apt-get install libblas3 liblapack3 liblapack-dev libblas-dev
Your nextissue is very likely going to be a missing Fortran compiler, resolve this by installing it like this:
您的下一个问题很可能是缺少 Fortran 编译器,请通过如下安装来解决此问题:
sudo apt-get install gfortran
If you have any issue with a missing Python.h file like this:
如果您对缺少的 Python.h 文件有任何问题,如下所示:
Python.h: No such file or directory
Python.h:没有这样的文件或目录
Then have a look at this post: https://stackoverflow.com/a/21530768/209532
然后看看这个帖子:https: //stackoverflow.com/a/21530768/209532
回答by Vincenzooo
I got this problem on freeBSD. It seems lapack packages are missing, I solved it installing them (as root) with:
我在 freeBSD 上遇到了这个问题。似乎缺少 lapack 软件包,我解决了安装它们(以 root 身份)的问题:
pkg install lapack
pkg install atlas-devel #not sure this is needed, but just in case
I imagine it could work on other system too using the appropriate package installer (e.g. apt-get)
我想它也可以使用适当的软件包安装程序(例如 apt-get)在其他系统上工作
回答by Mike N
pip install Cython
pip install Cython
before
前
pip install sklearn
pip install sklearn
did the trick for me.
帮我解决了这个问题。
回答by Marco Sulla
Always for Ubuntu/Debian, chjortlund's answerit's very good but not perfect, since this way you get an unoptimized BLAS library. You have simply to do:
对于 Ubuntu/Debian,chjortlund 的回答总是很好,但并不完美,因为这样你会得到一个未优化的 BLAS 库。你只需要做:
sudo apt install libatlas-base-dev
and voila'!
瞧!