'No BLAS/LAPACK libraries found when installing SciPy on macOS
I am using python 3.9.8 and pycharm on a macbook m1.
I have already installed openblas with homebrew but I still get the error below.
I tried installing SciPy via homebrew, but it didn't work properly.
My pip is up to date.
I installed Numpy, Pandas etc. Everything works fine except SciPy and I can't figure out why.
(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.
Solution 1:[1]
I encountered the same issue, using Homebrew based Python 3.10 installation and installing Poetry based package depending on Scipy.
The error was:
numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries found. Note: Accelerate is no longer supported.
How I fixed this:
# 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
And then attempting to install the packages again with:
# Install deps
poetry install
poetry / pip / etc. installation methods should be interchangeable.
SciPy 1.6.1 installation will take some time, but this time will complete.
- Tip about how
LAPACK
environment variable works
Some of the official documentation (less useful):
Solution 2:[2]
Mikko Ohtamaa's method didn't work for me.. I could see why, my brew packages happened to be installed somewhere else and some of the libraries were slightly newer.
It's worth being aware of this. You can see where brew puts stuff easily by just doing this after installing openblas:
brew info openblas
So in the end I had to do:
brew install openblas lapack
export LDFLAGS="-L/opt/homebrew/opt/lapack/lib"
export LDFLAGS="-L/opt/homebrew/opt/lapack/include"
export LDFLAGS="-L/opt/homebrew/opt/lapack/lib"
export CPPFLAGS="-L/opt/homebrew/opt/lapack/include"
export PKG_CONFIG_PATH="-L/opt/homebrew/opt/lapack/pkgconfig"
export CFLAGS=-Wno-error=implicit-function-declaration
export LAPACK=/opt/homebrew/opt/lapack/lib/liblapack.dylib
export BLAS=/opt/homebrew/opt/openblas/lib/libopenblasp-r0.3.20.dylib
poetry install
Still, I'd be nowhere without Mikko's answer. I've tried a couple of other methods that didn't work, so I don't know if that's because I'm on a newer M1 or because brew changed or what..
Solution 3:[3]
I downloaded conda and now it works just fine.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | |
Solution 3 | Wes |