scipy: Unable to install scipy on macOS Big Sur (Intel hardware)

After Big Sur update I’m not able to install scipy in any of my virtualenvs.

pip install scipy

generate this error

    numpy.distutils.system_info.NotFoundError: No lapack/blas resources found. Note: Accelerate is no longer supported.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/ernestoarbitrio/.virtualenvs/histolab/bin/python /Users/ernestoarbitrio/.virtualenvs/histolab/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/3j/s7l7gl410xx64sk3zg9_ngh40000gn/T/tmppxmdgj6o Check the logs for full command output.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 77
  • Comments: 76 (29 by maintainers)

Commits related to this issue

Most upvoted comments

Wow, this worked. Thank you:

Install openblas:

$ brew install openblas

I used pip3 to install scipy

$ SYSTEM_VERSION_COMPAT=1 \
LDFLAGS="-L/usr/local/opt/openblas/lib" \
CPPFLAGS="-I/usr/local/opt/openblas/include" \
OPENBLAS="$(brew --prefix openblas)" \
pip3 install scipy

Success!!!

Collecting scipy
  Downloading scipy-1.6.3-cp38-cp38-macosx_10_9_x86_64.whl (30.8 MB)
     |████████████████████████████████| 30.8 MB 128 kB/s
Requirement already satisfied: numpy<1.23.0,>=1.16.5 in ./env/lib/python3.8/site-packages (from scipy) (1.19.2)
Installing collected packages: scipy
Successfully installed scipy-1.6.3

For anyone else that needs SciPy to just install for now, here’s what I did to make it work:

  1. Find your tag
$ pip install packaging
$ python -c"from packaging import tags; print('\n'.join([str(t) for t in tags.sys_tags()]))" |head -5

cp38-cp38-macosx_11_0_x86_64
  1. Download 10_9 wheel from Pypi https://pypi.org/project/scipy/#files

  2. Rename downloaded file to match your tag $ mv scipy-1.5.4-cp38-cp38-macosx_10_9_x86_64.whl scipy-1.5.4-cp38-cp38-macosx_11_0_x86_64.whl

  3. Install wheel $ pip install scipy-1.5.4-cp38-cp38-macosx_11_0_x86_64.whl

updating pip did the trick for me (current version 20.3.3) - macOS Big Sur.

Fwiw, I managed to install scipy on Big Sur (Intel Macbook) by using the compatibility mode, in which macOS will report being version 10.16 instead of 11.0:

export SYSTEM_VERSION_COMPAT=1
> sw_vers -productVersion
10.16

Fwiw, I managed to install scipy on Big Sur (Intel Macbook) by using the compatibility mode, in which macOS will report being version 10.16 instead of 11.0:

export SYSTEM_VERSION_COMPAT=1
> sw_vers -productVersion
10.16

This made the trick! Thanks so much for your answer… It works!

Hello! I could finally install scipy on Mac OSX Big Sur thanks to @denizdogan. In my case, since I only needed scipy this is what I did.

brew install openblas

Then I executed the following:

SYSTEM_VERSION_COMPAT=1 \
LDFLAGS="-L/usr/local/opt/openblas/lib" \
CPPFLAGS="-I/usr/local/opt/openblas/include" \
OPENBLAS="$(brew --prefix openblas)" \
poetry add scipy

And it got installed successfully!

Intel Mac, Big Sur 11.2, pip 21.0.1 (also 20.3.1), poetry 1.1.4, Python 3.9.1.

I hit this same issue while updating a poetry-managed virtualenv today:

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.

After many years of reporting its system version as 10.x, macOS Big Sur reports itself as version 11.x. This breaks various things, including some parts of the Python packaging ecosystem. While we wait for package maintainers to publish 11.x wheels (no rush and we appreciate what you do!), any workaround that maps 10.x forward to 11.x (like renaming wheels), or maps 11.x back to 10.x, should fix the issue.

The easiest option I’ve found is SYSTEM_VERSION_COMPAT=1 <poetry|pip|pyenv|etc> <command>. This env var causes macOS to return a version string of 10.x (currently 10.16) instead of 11.x. For scipy, this will find the wheel scipy-1.6.1-cp39-cp39-macosx_10_9_x86_64.whl instead of building from source.

I think this is solved with the new release of pip, which added support for macOSx 11 to install wheels with a 10_9 tag.

I found this thread looking for a way to install librosa on macOS Big Sur 11.1 on Macbook Pro Intel. librosa depends on llvmlite, numpy, and scipy and I had various issues installing each of those dependencies. Finally, I have found a way that works for me and hopefully, this will help someone else.

First of all, you will need to install llvm@9 and openblas from Homebrew:

$ brew install llvm@9 openblas

After that, you will need to pass a bunch of environment variables to the poetry add librosa command, as described here and other places on the web:

$ SYSTEM_VERSION_COMPAT=1 \
LDFLAGS="-L/usr/local/opt/openblas/lib -L/usr/local/opt/llvm@9/lib -Wl,-rpath,/usr/local/opt/llvm@9/lib" \
CPPFLAGS="-I/usr/local/opt/openblas/include -I/usr/local/opt/llvm/include" \
LLVM_CONFIG=$(brew --prefix llvm@9)/bin/llvm-config \
OPENBLAS="$(brew --prefix openblas)" \
poetry add librosa

Done!

In case you’re having issues, here’s the exact versions of everything I’m using:

  • llvm@9: stable 9.0.1 (bottled) [keg-only]
  • openblas: stable 0.3.13 (bottled), HEAD [keg-only]
  • GNU Fortran (Homebrew GCC 10.2.0_3) 10.2.0
  • Apple clang version 12.0.0 (clang-1200.0.32.28)
  • Python 3.8.7
  • Poetry version 1.1.4
  • pip 21.0

I was able to manually install the wheel by going here https://pypi.org/project/scipy/#files and downloading the cPython 3.7 wheel and running. pip install scipy-1.5.4-cp37-cp37m-macosx_10_9_x86_64.whl

The first time it errored out with the message scipy-1.5.4-cp37-cp37m-macosx_10_9_x86_64.whl is not a supported wheel on this platform.

I renamed the wheel to scipy-1.5.4-cp37-none-any.whl and ran pip install scipy-1.5.4-cp37-none-any.whl and it worked.

I am guessing pip is looking for scipy-1.5.4-cp37-cp37m-macosx_11_0_x86_64.whl on BigSur or something.

We ran into this recently as well (using scipy 1.7.0 and Python 3.7.10 together), and what worked for us was:

  • xcode-select --install before anything, with latest XCode from App Store
  • brew install pyenv
  • pyenv install 3.7.10 && pyenv global 3.7.10
  • SYSTEM_VERSION_COMPAT=1 pip install scipy

We actually use Pipenv, and it helped to split SYSTEM_VERSION_COMPAT=1 pipenv lock and pipenv sync, though likely due to our other dependencies.

For me simply upgrading pip solved the problem: pip install -U pip

Fwiw, I managed to install scipy on Big Sur (Intel Macbook) by using the compatibility mode, in which macOS will report being version 10.16 instead of 11.0:

export SYSTEM_VERSION_COMPAT=1
> sw_vers -productVersion
10.16

This works for me (Big Sur).

I am having the same issue on both Apple Silicon, and Intel. This was working correctly on BigSur a week or two ago but seems to have stopped. I have noticed that a couple of other python libraries with C extensions have quit working too. Checked out devdocs and installing openblas (brew install openblas) did not help.

update pip

I think this is solved with the new release of pip, which added support for macOSx 11 to install wheels with a 10_9 tag.

Updating pip version to 21.3.1 solves this problem for me

I think this is solved with the new release of pip, which added support for macOSx 11 to install wheels with a 10_9 tag.

Still failing for me (using pyenv) with latest pip (pip 20.3 from /Users/myuser/.pyenv/versions/3.8.6/lib/python3.8/site-packages/pip (python 3.8)

There are Python 3.10 wheels for x86_64 and arm64 at https://pypi.org/project/scipy/1.8.0/#files. The only thing that won’t be supported is if you’re on macOS 11.x and want arm64 scipy. Upgrade to macOS 12 and pip install scipy will work.

I successfully installed it on Big Sur with M1 Architecture, by using miniconda! Just by doing conda install scipy …!

This is all fixed in pip. Let’s document the solutions, there are two:

  1. Upgrade to most recent version of pip (preferred).
  2. For older versions of pip, the problem can be worked around by export SYSTEM_VERSION_COMPAT=1.

This issue was for macOS Big Sur on Intel hardware. There are separate issues for arm64 (M1) hardware. I’ll close this issue.

None of the solutions listed here were working for me. What ultimately worked was:

brew install scipy

It installed python3.9 in the process at this location /opt/homebrew/Cellar/python@3.9/3.9.6/bin/python3, so I have to run this python executable to use import scipy.

This actually didn’t work… When I tried to import sklearn the import failed. @tommydangerous’s solution worked for me! In a Rosetta terminal on macOS Big Sur with the Apple M1 chip.

None of the solutions listed here were working for me. What ultimately worked was:

brew install scipy

It installed python3.9 in the process at this location /opt/homebrew/Cellar/python@3.9/3.9.6/bin/python3, so I have to run this python executable to use import scipy.

For me using python 3.9.5 instead of 3.10 solved the issue.

I was able to resolve this morning with a similar solution. Mac OS 11.6 / Intel Steps:

  • Remove Python 3.10 and any lingering caches it had left behind
  • Install Python 3.9.7
  • Create vevn: python3 -m venv ~/pyvenv3.9.7
  • Set venv as active python instance: source ~/pyvenv3.9.7/bin/activate
  • update pip: python3 -m pip install --upgrade pip
  • install scipy and other packages that were failing

macOS 11.3.1 Python 3.9.4 pyenv 1.2.27 pipenv 2020.11.15 pip 21.1.1 (this is latest at the time I’m writing) scipy 1.6.3 (not pinned, resolved by pipenv)

Trying to pipenv install scipy as a dependency for pipenv install lightgbm.

Only the export SYSTEM_VERSION_COMPAT=1 solution worked for me. Without this envvar, pipenv was falling back to building from source instead of downloading a wheel.

I confirmed the pip version in the virtual environment with pipenv run pip --version, and pinned it as described elsewhere with export VIRTUALENV_PIP=21.1.1, but this did not help with the pipenv install scipy.

TBH i don’t really know why such a big difference of behaviour between these two python distro.

They don’t use the same binaries for installation, among other things

@kkozmic what did you try and what was the error?

I’m using Poetry (1.1.4), running poetry install on my project, so can’t easily go around downloading/renaming files. This is under Python 3.8.6 and pip 20.3 in pyenv running on an Intel Macbook Pro with Big Sur 11.0.1

Full log. Click to expand (long)

  • Installing scipy (1.5.2): Failed

  EnvCommandError

  Command ['/Users/my-user/projects/my-project/.venv/bin/pip', 'install', '--no-deps', 'file:///Users/my-user/Library/Caches/pypoetry/artifacts/2f/b1/6e/302949c7b1aeb2d81b181900de55a0504d2060e751aa6c2e3985b4b4fb/scipy-1.5.2.tar.gz'] errored with the following return code 1, and output:
  Processing /Users/my-user/Library/Caches/pypoetry/artifacts/2f/b1/6e/302949c7b1aeb2d81b181900de55a0504d2060e751aa6c2e3985b4b4fb/scipy-1.5.2.tar.gz
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
      Preparing wheel metadata: started
      Preparing wheel metadata: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /Users/my-user/projects/my-project/.venv/bin/python /Users/my-user/projects/my-project/.venv/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/tmp6l431_j2
           cwd: /private/var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/pip-req-build-ggiz013l
      Complete output (139 lines):
      lapack_opt_info:
      lapack_mkl_info:
      customize UnixCCompiler
        libraries mkl_rt not found in ['/Users/my-user/projects/my-project/.venv/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      openblas_lapack_info:
      customize UnixCCompiler
      customize UnixCCompiler
        libraries openblas not found in ['/Users/my-user/projects/my-project/.venv/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      openblas_clapack_info:
      customize UnixCCompiler
      customize UnixCCompiler
        libraries openblas,lapack not found in ['/Users/my-user/projects/my-project/.venv/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      flame_info:
      customize UnixCCompiler
        libraries flame not found in ['/Users/my-user/projects/my-project/.venv/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      atlas_3_10_threads_info:
      Setting PTATLAS=ATLAS
      customize UnixCCompiler
        libraries lapack_atlas not found in /Users/my-user/projects/my-project/.venv/lib
      customize UnixCCompiler
        libraries tatlas,tatlas not found in /Users/my-user/projects/my-project/.venv/lib
      customize UnixCCompiler
        libraries lapack_atlas not found in /usr/local/lib
      customize UnixCCompiler
        libraries tatlas,tatlas not found in /usr/local/lib
      customize UnixCCompiler
        libraries lapack_atlas not found in /usr/lib
      customize UnixCCompiler
        libraries tatlas,tatlas not found in /usr/lib
      <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
        NOT AVAILABLE

      atlas_3_10_info:
      customize UnixCCompiler
        libraries lapack_atlas not found in /Users/my-user/projects/my-project/.venv/lib
      customize UnixCCompiler
        libraries satlas,satlas not found in /Users/my-user/projects/my-project/.venv/lib
      customize UnixCCompiler
        libraries lapack_atlas not found in /usr/local/lib
      customize UnixCCompiler
        libraries satlas,satlas not found in /usr/local/lib
      customize UnixCCompiler
        libraries lapack_atlas not found in /usr/lib
      customize UnixCCompiler
        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
      customize UnixCCompiler
        libraries lapack_atlas not found in /Users/my-user/projects/my-project/.venv/lib
      customize UnixCCompiler
        libraries ptf77blas,ptcblas,atlas not found in /Users/my-user/projects/my-project/.venv/lib
      customize UnixCCompiler
        libraries lapack_atlas not found in /usr/local/lib
      customize UnixCCompiler
        libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
      customize UnixCCompiler
        libraries lapack_atlas not found in /usr/lib
      customize UnixCCompiler
        libraries ptf77blas,ptcblas,atlas not found in /usr/lib
      <class 'numpy.distutils.system_info.atlas_threads_info'>
        NOT AVAILABLE

      atlas_info:
      customize UnixCCompiler
        libraries lapack_atlas not found in /Users/my-user/projects/my-project/.venv/lib
      customize UnixCCompiler
        libraries f77blas,cblas,atlas not found in /Users/my-user/projects/my-project/.venv/lib
      customize UnixCCompiler
        libraries lapack_atlas not found in /usr/local/lib
      customize UnixCCompiler
        libraries f77blas,cblas,atlas not found in /usr/local/lib
      customize UnixCCompiler
        libraries lapack_atlas not found in /usr/lib
      customize UnixCCompiler
        libraries f77blas,cblas,atlas not found in /usr/lib
      <class 'numpy.distutils.system_info.atlas_info'>
        NOT AVAILABLE

      accelerate_info:
        NOT AVAILABLE

      lapack_info:
      customize UnixCCompiler
        libraries lapack not found in ['/Users/my-user/projects/my-project/.venv/lib', '/usr/local/lib', '/usr/lib']
        NOT AVAILABLE

      lapack_src_info:
        NOT AVAILABLE

        NOT AVAILABLE

      setup.py:460: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /private/var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/pip-modern-metadata-ug779qrr'), proceeding with generating Cython sources and expanding templates
        warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
      Running from SciPy source directory.
      /private/var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/pip-build-env-p8fk30ek/overlay/lib/python3.8/site-packages/numpy/distutils/system_info.py:1712: 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.
        if getattr(self, '_calc_info_{}'.format(lapack))():
      /private/var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/pip-build-env-p8fk30ek/overlay/lib/python3.8/site-packages/numpy/distutils/system_info.py:1712: 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.
        if getattr(self, '_calc_info_{}'.format(lapack))():
      Traceback (most recent call last):
        File "/Users/my-user/projects/my-project/.venv/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
          main()
        File "/Users/my-user/projects/my-project/.venv/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/my-user/projects/my-project/.venv/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 133, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/private/var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/pip-build-env-p8fk30ek/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 161, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/private/var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/pip-build-env-p8fk30ek/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 253, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/private/var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/pip-build-env-p8fk30ek/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 145, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 583, in <module>
          setup_package()
        File "setup.py", line 579, in setup_package
          setup(**metadata)
        File "/private/var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/pip-build-env-p8fk30ek/overlay/lib/python3.8/site-packages/numpy/distutils/core.py", line 137, in setup
          config = configuration()
        File "setup.py", line 477, in configuration
          raise NotFoundError(msg)
      numpy.distutils.system_info.NotFoundError: No lapack/blas resources found. Note: Accelerate is no longer supported.
      ----------------------------------------
  ERROR: Command errored out with exit status 1: /Users/my-user/projects/my-project/.venv/bin/python /Users/my-user/projects/my-project/.venv/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/ls/j8gt2mcd02s9z5yqbgt297h80000gn/T/tmp6l431_j2 Check the logs for full command output.

It still does not work with Python 3.10.1 even when updating pip to the latest version. It does work if I revert to Python 3.9.10 instead. Such a pity, I so want to use structural pattern matching!

No, we cannot use Accelerate in SciPy, and the NumPy wheels don’t use Accelerate (all wheels ship with OpenBLAS). So there’s nothing that changed with the reintroduction of Accelerate besides from-source builds.

For me using python 3.9.5 instead of 3.10 solved the issue.

@tommydangerous 's solution worked for me on apple silicon. cheers!

If you’re using poetry, I was able to successfully install by running poetry self update and poetry run pip install --upgrade pip though you don’t have to update poetry.

After this poetry install worked just fine for me and I was able to run the project just fine.

@V0lantis You don’t need Poetry to get it working, pip should be fine. 😃 Replace poetry add X with pip install X and hopefully, that should work. If you still want to use Poetry, you should run poetry init, but better yet, just read the official Poetry documentation, it’s pretty simple: https://python-poetry.org/docs/basic-usage/

As apple being apple, there was some dynamic linking changing stuff happening (see for example a similar issue for R https://github.com/sethrfore/homebrew-r-srf/issues/35#issuecomment-730396499)

So your poetry machinery is not finding the system packages related to BLAS/LAPACK libraries.

But yes that’s your understanding is correct. Even then, it should be possible to build it on the fly on MacOS without any issues. Then again, I’m not a mac person so your guess is as good as mine. Let’s see if more knowledgeable peepz can figure it out.

But until then uploading renamed wheels would help.

Whelp, that doesn’t work, pypi refuses the renamed files as duplicates.

Uploading numpy-1.19.4-cp37-cp37m-macosx_11_0_x86_64.whl
100%|███████████████████████████████████████████████████████████████████████████████████████████████| 14.6M/14.6M [00:53<00:00, 288kB/s]
NOTE: Try --verbose to see response content.
HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
File already exists. See https://pypi.org/help/#file-name-reuse for more information.

All bets are off for apple silicon, I don’t think we’ve tried building on there yet, but it’ll come.

Not sure about Big Sur and Intel though, I would’ve thought building would work there. However, it’s not clear why a prebuilt wheel isn’t being installed to start with. Does numpy install and run its test suite ok?

Check out the devdocs, http://scipy.github.io/devdocs/building/macosx.html, they may help.