在 macOS 上安装 SciPy 时未找到 BLAS/LAPACK 库
Posted
技术标签:
【中文标题】在 macOS 上安装 SciPy 时未找到 BLAS/LAPACK 库【英文标题】:No BLAS/LAPACK libraries found when installing SciPy on macOS 【发布时间】:2021-12-25 11:46:42 【问题描述】:我在 macbook m1 上使用 python 3.9.8 和 pycharm。 我已经用自制软件安装了 openblas,但我仍然收到以下错误。 我尝试通过自制软件安装 SciPy,但无法正常工作。 我的点子是最新的。
我安装了 Numpy、Pandas 等。除了 SciPy 外一切正常,我不知道为什么。
(venv) wes@Air-van-Wes pythonProject % pip install scipy
Collecting scipy
Using cached scipy-1.7.2.tar.gz (36.1 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
ERROR: Command errored out with exit status 1:
command: /Users/wes/PycharmProjects/pythonProject/venv/bin/python /Users/wes/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/tmpgb5a46oi
cwd: /private/var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/pip-install-19slhbw2/scipy_f4bfaae68a1e4c2db88f86a394b879ca
Complete output (175 lines):
setup.py:491: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /private/var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/pip-modern-metadata-6yn5g0q3'), proceeding with generating Cython sources and expanding templates
warnings.warn("Unrecognized setuptools command (''), proceeding with "
Running from SciPy source directory.
Running scipy/linalg/_generate_pyx.py
Running scipy/special/_generate_pyx.py
Running scipy/stats/_generate_pyx.py
Processing scipy/cluster/_vq.pyx
Processing scipy/cluster/_optimal_leaf_ordering.pyx
Processing scipy/cluster/_hierarchy.pyx
Processing scipy/ndimage/src/_cytest.pyx
Processing scipy/ndimage/src/_ni_label.pyx
Processing scipy/linalg/cython_lapack.pyx
Processing scipy/linalg/_matfuncs_sqrtm_triu.pyx
Processing scipy/linalg/_solve_toeplitz.pyx
Processing scipy/linalg/cython_blas.pyx
Processing scipy/linalg/_decomp_update.pyx.in
Processing scipy/optimize/_group_columns.pyx
Processing scipy/optimize/_bglu_dense.pyx
Processing scipy/optimize/_trlib/_trlib.pyx
Processing scipy/optimize/_highs/cython/src/_highs_constants.pyx
Processing scipy/optimize/_highs/cython/src/_highs_wrapper.pyx
Processing scipy/optimize/_lsq/givens_elimination.pyx
Processing scipy/optimize/cython_optimize/_zeros.pyx.in
Processing scipy/io/matlab/mio_utils.pyx
Processing scipy/io/matlab/streams.pyx
Processing scipy/io/matlab/mio5_utils.pyx
Processing scipy/_lib/_ccallback_c.pyx
Processing scipy/_lib/_test_deprecation_def.pyx
Processing scipy/_lib/_test_deprecation_call.pyx
Processing scipy/_lib/messagestream.pyx
Processing scipy/special/_ufuncs_cxx.pyx
Processing scipy/special/cython_special.pyx
Processing scipy/special/_ellip_harm_2.pyx
Processing scipy/special/_comb.pyx
Processing scipy/special/_test_round.pyx
Processing scipy/special/_ufuncs.pyx
Processing scipy/fftpack/convolve.pyx
Processing scipy/interpolate/interpnd.pyx
Processing scipy/interpolate/_bspl.pyx
Processing scipy/interpolate/_ppoly.pyx
Processing scipy/sparse/_csparsetools.pyx.in
Processing scipy/sparse/csgraph/_shortest_path.pyx
Processing scipy/sparse/csgraph/_traversal.pyx
Processing scipy/sparse/csgraph/_flow.pyx
Processing scipy/sparse/csgraph/_tools.pyx
warning: _cython_special_custom.pxi:9:8: Unreachable code
warning: _cython_special_custom.pxi:13:4: Unreachable code
warning: _cython_special_custom.pxi:21:8: Unreachable code
warning: _cython_special_custom.pxi:25:4: Unreachable code
warning: _cython_special_custom.pxi:33:8: Unreachable code
warning: _cython_special_custom.pxi:37:4: Unreachable code
warning: _cython_special_custom.pxi:45:8: Unreachable code
warning: _cython_special_custom.pxi:49:4: Unreachable code
Processing scipy/sparse/csgraph/_matching.pyx
Processing scipy/sparse/csgraph/_reordering.pyx
Processing scipy/sparse/csgraph/_min_spanning_tree.pyx
Processing scipy/spatial/ckdtree.pyx
Processing scipy/spatial/_voronoi.pyx
Processing scipy/spatial/_hausdorff.pyx
Processing scipy/spatial/qhull.pyx
Processing scipy/spatial/transform/rotation.pyx
Processing scipy/signal/_max_len_seq_inner.pyx
Processing scipy/signal/_peak_finding_utils.pyx
Processing scipy/signal/_upfirdn_apply.pyx
Processing scipy/signal/_spectral.pyx
Processing scipy/signal/_sosfilt.pyx
Processing scipy/stats/_stats.pyx
Processing scipy/stats/_qmc_cy.pyx
Processing scipy/stats/_sobol.pyx
Processing scipy/stats/biasedurn.pyx
Processing scipy/stats/_boost/src/beta_ufunc.pyx
Processing scipy/stats/_boost/src/nbinom_ufunc.pyx
Processing scipy/stats/_boost/src/binom_ufunc.pyx
Cythonizing sources
lapack_opt_info:
lapack_mkl_info:
customize UnixCCompiler
libraries mkl_rt not found in ['/Users/wes/PycharmProjects/pythonProject/venv/lib', '/usr/lib']
NOT AVAILABLE
openblas_lapack_info:
libraries openblas not found in ['/Users/wes/PycharmProjects/pythonProject/venv/lib', '/usr/lib']
NOT AVAILABLE
openblas_clapack_info:
libraries openblas,lapack not found in ['/Users/wes/PycharmProjects/pythonProject/venv/lib', '/usr/lib']
NOT AVAILABLE
flame_info:
libraries flame not found in ['/Users/wes/PycharmProjects/pythonProject/venv/lib', '/usr/lib']
NOT AVAILABLE
accelerate_info:
NOT AVAILABLE
atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
libraries lapack_atlas not found in /Users/wes/PycharmProjects/pythonProject/venv/lib
libraries tatlas,tatlas not found in /Users/wes/PycharmProjects/pythonProject/venv/lib
libraries lapack_atlas not found in /usr/lib
libraries tatlas,tatlas not found in /usr/lib
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
NOT AVAILABLE
atlas_3_10_info:
libraries lapack_atlas not found in /Users/wes/PycharmProjects/pythonProject/venv/lib
libraries satlas,satlas not found in /Users/wes/PycharmProjects/pythonProject/venv/lib
libraries lapack_atlas not found in /usr/lib
libraries satlas,satlas not found in /usr/lib
<class 'numpy.distutils.system_info.atlas_3_10_info'>
NOT AVAILABLE
atlas_threads_info:
Setting PTATLAS=ATLAS
libraries lapack_atlas not found in /Users/wes/PycharmProjects/pythonProject/venv/lib
libraries ptf77blas,ptcblas,atlas not found in /Users/wes/PycharmProjects/pythonProject/venv/lib
libraries lapack_atlas not found in /usr/lib
libraries ptf77blas,ptcblas,atlas not found in /usr/lib
<class 'numpy.distutils.system_info.atlas_threads_info'>
NOT AVAILABLE
atlas_info:
libraries lapack_atlas not found in /Users/wes/PycharmProjects/pythonProject/venv/lib
libraries f77blas,cblas,atlas not found in /Users/wes/PycharmProjects/pythonProject/venv/lib
libraries lapack_atlas not found in /usr/lib
libraries f77blas,cblas,atlas not found in /usr/lib
<class 'numpy.distutils.system_info.atlas_info'>
NOT AVAILABLE
lapack_info:
libraries lapack not found in ['/Users/wes/PycharmProjects/pythonProject/venv/lib', '/usr/lib']
NOT AVAILABLE
/private/var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/pip-build-env-4znp06oe/overlay/lib/python3.9/site-packages/numpy/distutils/system_info.py:1858: 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.
return getattr(self, '_calc_info_'.format(name))()
lapack_src_info:
NOT AVAILABLE
/private/var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/pip-build-env-4znp06oe/overlay/lib/python3.9/site-packages/numpy/distutils/system_info.py:1858: 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.
return getattr(self, '_calc_info_'.format(name))()
NOT AVAILABLE
Traceback (most recent call last):
File "/Users/wes/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/Users/wes/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/Users/wes/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/private/var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/pip-build-env-4znp06oe/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 166, in prepare_metadata_for_build_wheel
self.run_setup()
File "/private/var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/pip-build-env-4znp06oe/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 258, in run_setup
super(_BuildMetaLegacyBackend,
File "/private/var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/pip-build-env-4znp06oe/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 150, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 631, in <module>
setup_package()
File "setup.py", line 627, in setup_package
setup(**metadata)
File "/private/var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/pip-build-env-4znp06oe/overlay/lib/python3.9/site-packages/numpy/distutils/core.py", line 135, in setup
config = configuration()
File "setup.py", line 529, in configuration
raise NotFoundError(msg)
numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries found. Note: Accelerate is no longer supported.
To build Scipy from sources, BLAS & LAPACK libraries need to be installed.
See site.cfg.example in the Scipy source directory and
https://docs.scipy.org/doc/scipy/reference/building/index.html for details.
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/0e/23/58c4f995475a2a97cb5f4a032aedaf881ad87cd976a7180c55118d105a1d/scipy-1.7.2.tar.gz#sha256=fa2dbabaaecdb502641b0b3c00dec05fb475ae48655c66da16c9ed24eda1e711 (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.11). Command errored out with exit status 1: /Users/wes/PycharmProjects/pythonProject/venv/bin/python /Users/wes/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/bl/2xjy80bj6y57yb5z0frfypk00000gn/T/tmpgb5a46oi Check the logs for full command output.
【问题讨论】:
请注意,错误消息指向docs.scipy.org/doc/scipy/reference/building/index.html,其中有一个关于在 macOS 上编译的部分,包括安装 BLAS 和 LAPACK 的说明。 是的,它说通过自制软件安装它,我做了。但即使我安装了 openBLAS,它仍然给我这个错误。 您是否也检查过并在必要时编辑了错误消息中前面提到的 site.cfg 文件? 【参考方案1】:我下载了 conda,现在可以正常使用了。
【讨论】:
您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center。【参考方案2】:我遇到了同样的问题,使用基于 Homebrew 的 Python 3.10 安装并安装 Poetry based package depending on Scipy。
错误是:
numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries found. Note: Accelerate is no longer supported.
我是如何解决这个问题的:
# Install lapack and openblas from Homebrew
brew install openblas lapack
# Tell Numpy installer where to find lapack
export LDFLAGS="-L/usr/local/opt/lapack/lib"
export CPPFLAGS="-I/usr/local/opt/lapack/include"
export PKG_CONFIG_PATH="/usr/local/opt/lapack/lib/pkgconfig"
# See https://github.com/scipy/scipy/issues/12935
export CFLAGS=-Wno-error=implicit-function-declaration
# The location may vary - use find command to find this on your local /usr/local/opt
export LAPACK=/usr/local/opt/lapack/lib/liblapack.dylib
export BLAS=/usr/local/opt/openblas/lib/libopenblasp-r0.3.19.dylib
然后尝试再次安装软件包:
# Install deps
poetry install
poetry/pip/等安装方式应该可以互换。
SciPy 1.6.1 安装需要一些时间,但这段时间会完成。
提示howLAPACK
environment variable works
一些官方文档(用处不大):
The official Scipy installation instructions.
The official LAPACK installation instructions
【讨论】:
以上是关于在 macOS 上安装 SciPy 时未找到 BLAS/LAPACK 库的主要内容,如果未能解决你的问题,请参考以下文章
尝试使用 Python 3.6 安装 pyjinius 时未找到与 pyjinius 匹配的发行版
在 MacOS 上安装 Spyder/Python - 非常令人沮丧
Windows Scipy 安装:未找到 Lapack/Blas 资源