在MacOS上安装SciPy时未找到BLAS/LAPACK库

No BLAS/LAPACK libraries found when installing SciPy on macOS(在MacOS上安装SciPy时未找到BLAS/LAPACK库)

本文介绍了在MacOS上安装SciPy时未找到BLAS/LAPACK库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MacBook M1上使用python3.9.8和pycharm。 我已经使用自制软件安装了openblas,但仍然收到下面的错误。
我尝试通过自制软件安装SciPy,但无法正常工作。
我的pip是最新的。

我安装了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.

推荐答案

我在使用基于Homebrew的Python3.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

诗歌/pip/等安装方法应可互换。

安装SciPy 1.6.1需要一些时间,但此时间将完成。

  • 关于how LAPACK environment variable works
  • 的提示

部分官方文档(用处较少):

  • The official Scipy installation instructions。

  • The official LAPACK installation instructions

这篇关于在MacOS上安装SciPy时未找到BLAS/LAPACK库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在MacOS上安装SciPy时未找到BLAS/LAPACK库