scipy: BUG: pip install scipy from git fails with `"openblas" not found`

Describe your issue.

This comes from SymPy CI: https://github.com/sympy/sympy/pull/23513

A few days ago it successfully built and tested NumPy and SciPy on Python 3.11b1 from git using pip but now the same setup fails to build SciPy with

      ../../scipy/meson.build:120:0: ERROR: Dependency "openblas" not found, tried pkgconfig and cmake

Maybe this would work with apt install libopenblas-dev liblapack-dev but it was working before so should it be expected to work still?

This was the last successful run (the build was successful although a test later failed): https://github.com/sympy/sympy/runs/6598088659?check_suite_focus=true

Reproducing Code Example

# Ubuntu 20.04.4 with Python 3.11b1 running in GA
sudo apt install antlr4 libgfortran5 gfortran libmpfr-dev libmpc-dev
pip install --upgrade pip wheel
pip install git+https://github.com/cython/cython@master
pip install git+https://github.com/numpy/numpy@main
pip install git+https://github.com/scipy/scipy@main

Error message

Run pip install git+https://github.com/numpy/numpy@main
  pip install git+https://github.com/numpy/numpy@main
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.11.0-beta.1/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.0-beta.1/x64/lib
Collecting git+https://github.com/numpy/numpy@main
  Cloning https://github.com/numpy/numpy (to revision main) to /tmp/pip-req-build-a992dsfx
  Running command git clone --filter=blob:none --quiet https://github.com/numpy/numpy /tmp/pip-req-build-a992dsfx
  Resolved https://github.com/numpy/numpy to commit 68f3a12f4cc9310a7d60f9878af72cf98e7233f3
  Running command git submodule update --init --recursive -q
  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 metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: numpy
  Building wheel for numpy (pyproject.toml): started
  Building wheel for numpy (pyproject.toml): still running...
  Building wheel for numpy (pyproject.toml): still running...
  Building wheel for numpy (pyproject.toml): still running...
  Building wheel for numpy (pyproject.toml): still running...
  Building wheel for numpy (pyproject.toml): finished with status 'done'
  Created wheel for numpy: filename=numpy-1.24.0.dev0+75.g68f3a12f4-cp311-cp311-linux_x86_64.whl size=22029574 sha256=ed58cdbe5b547632f5a45e8ab48e0c200b8f247a91e8e945c457a7899185724a
  Stored in directory: /tmp/pip-ephem-wheel-cache-jo9owv4z/wheels/ad/e8/55/3b4372ddf4700df1fb35dc513aacd83756396e870c5a6f8ece
Successfully built numpy
Installing collected packages: numpy
Successfully installed numpy-1.24.0.dev0+75.g68f3a12f4

Run pip install git+https://github.com/scipy/scipy@main
Collecting git+https://github.com/scipy/scipy@main
  Cloning https://github.com/scipy/scipy (to revision main) to /tmp/pip-req-build-b76e9_br
  Running command git clone --filter=blob:none --quiet https://github.com/scipy/scipy /tmp/pip-req-build-b76e9_br
  Resolved https://github.com/scipy/scipy to commit 6c51ed7aa4230d9fc08d099773b66f61e9828e97
  Running command git submodule update --init --recursive -q
  Installing build dependencies: started
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: still running...
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [72 lines of output]
      The Meson build system
      Version: 0.62.1
      Source dir: /tmp/pip-req-build-b76e9_br
      Build dir: /tmp/pip-req-build-b76e9_br/.mesonpy-_wsc8qd3/build
      Build type: native build
      Project name: SciPy
      Project version: 1.9.0.dev0
      C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
      C linker for the host machine: cc ld.bfd 2.34
      C++ compiler for the host machine: c++ (gcc 9.4.0 "c++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
      C++ linker for the host machine: c++ ld.bfd 2.34
      Host machine cpu family: x86_64
      Host machine cpu: x86_64
      Compiler for C supports arguments -Wno-unused-but-set-variable: YES
      Library m found: YES
      Fortran compiler for the host machine: gfortran (gcc 9.4.0 "GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
      Fortran linker for the host machine: gfortran ld.bfd 2.34
      Program cython found: YES (/tmp/pip-build-env-4bh3e24n/overlay/bin/cython)
      Program pythran found: YES (/tmp/pip-build-env-4bh3e24n/overlay/bin/pythran)
      Program cp found: YES (/usr/bin/cp)
      Program python3 found: YES (/opt/hostedtoolcache/Python/3.11.0-beta.1/x64/bin/python)
      Found pkg-config: /usr/bin/pkg-config (0.29.1)
      Library npymath found: YES
      Library npyrandom found: YES
      Found CMake: /usr/local/bin/cmake (3.23.1)
      Run-time dependency openblas found: NO (tried pkgconfig and cmake)
      
      ../../scipy/meson.build:120:0: ERROR: Dependency "openblas" not found, tried pkgconfig and cmake
      
      A full log can be found at /tmp/pip-req-build-b76e9_br/.mesonpy-_wsc8qd3/build/meson-logs/meson-log.txt
      + meson setup --native-file=/tmp/pip-req-build-b76e9_br/.mesonpy-native-file.ini -Ddebug=false -Dstrip=true -Doptimization=2 --prefix=/opt/hostedtoolcache/Python/3.11.0-beta.1/x64 /tmp/pip-req-build-b76e9_br /tmp/pip-req-build-b76e9_br/.mesonpy-_wsc8qd3/build
      Traceback (most recent call last):
        File "/opt/hostedtoolcache/Python/3.11.0-beta.1/x64/lib/python3.11/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
          ^^^^^^
        File "/opt/hostedtoolcache/Python/3.11.0-beta.1/x64/lib/python3.11/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/hostedtoolcache/Python/3.11.0-beta.1/x64/lib/python3.11/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4bh3e24n/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 805, in get_requires_for_build_wheel
          with _project(config_settings) as project:
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/hostedtoolcache/Python/3.11.0-beta.1/x64/lib/python3.11/contextlib.py", line 137, in __enter__
          return next(self.gen)
                 ^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4bh3e24n/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 784, in _project
          with Project.with_temp_working_dir(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/hostedtoolcache/Python/3.11.0-beta.1/x64/lib/python3.11/contextlib.py", line 137, in __enter__
          return next(self.gen)
                 ^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4bh3e24n/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 479, in with_temp_working_dir
          yield cls(source_dir, tmpdir, build_dir)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4bh3e24n/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 423, in __init__
          self._configure(reconfigure=bool(build_dir) and not native_file_mismatch)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4bh3e24n/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 450, in _configure
          self._meson(
          ^^^^^^^^^^^^
        File "/tmp/pip-build-env-4bh3e24n/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 438, in _meson
          return self._proc('meson', *args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-4bh3e24n/overlay/lib/python3.11/site-packages/mesonpy/__init__.py", line 434, in _proc
          subprocess.check_call(list(args))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/hostedtoolcache/Python/3.11.0-beta.1/x64/lib/python3.11/subprocess.py", line 402, in check_call
          raise CalledProcessError(retcode, cmd)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      subprocess.CalledProcessError: Command '['meson', 'setup', '--native-file=/tmp/pip-req-build-b76e9_br/.mesonpy-native-file.ini', '-Ddebug=false', '-Dstrip=true', '-Doptimization=2', '--prefix=/opt/hostedtoolcache/Python/3.11.0-beta.1/x64', '/tmp/pip-req-build-b76e9_br', '/tmp/pip-req-build-b76e9_br/.mesonpy-_wsc8qd3/build']' returned non-zero exit status 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Error: Process completed with exit code 1.

SciPy/NumPy/Python version information

scipy/numpy from git and python 3.11b1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 65 (33 by maintainers)

Commits related to this issue

Most upvoted comments

I had the same issue as @oscarbenjamin, only on my Mac m1. Here my simple solution for Macos users:

  1. Ensure you have installed Openblas if not brew install openblas

  2. Then type brew info openblas. Check the output lines:

For compilers to find openblas you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/openblas/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/openblas/include"

For pkg-config to find openblas you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/openblas/lib/pkgconfig"

you may have other outputs.

  1. Write down these outputs in your .bashrc / bash_profile / .zshrc file. Then update your shell.

But also this is one of the items at #16293 and the goal is to teach Meson some of these fallback detection methods. 😃

I’m expecting the same question a bunch more times, so let’s leave this open for now so the issue and solution are more discoverable.

I think we have now gotten to the point where this issue is no longer helpful - too long and too many different errors being mixed in. We have docs at ~http://scipy.github.io/devdocs/dev/contributor/meson_advanced.html#select-a-different-blas-or-lapack-library~ http://scipy.github.io/devdocs/building/blas_lapack.html on how to switch to different BLAS/LAPACK libraries, and for new issues it’d be better if folks opened new issues. So I’ll close this. Thanks everyone!

The way I fixed it, is by finding my openblas.pc at /opt/homebrew/Cellar/openblas/0.3.21/lib/pkgconfig/openblas.pc and then do an export PKG_CONFIG_PATH=/opt/homebrew/Cellar/openblas/0.3.21/lib/pkgconfig. That fixed the installation problem.

As a datapoint, I was helping a user of a downstream package the other day, and he was having a bunch of incompehensible errors pointing at pkg-config. After several iterations, it turned out all these disappeared once he installed python and pkg-config inside of a conda env. This might be specific to macOS / anaconda combo though.

Mixing conda- and homebrew-installed bits seems to be brittle.

@lucascolley , thanks 🙏 that really helped

      Run-time dependency openblas found: YES 0.3.21-4.fc38
      Dependency openblas found: YES 0.3.21-4.fc38 (cached)

@rgommers, I added my own openblas.pc based on your template sample, set the PKG_CONFIG_PATH, and was able to build scipy successfully - and got my TVM build and install complete as well. Thank you for the assist!

I am noticing the scipy build is picking up the system versions of cmake (3.20.2) and pkg-config (1.4.2), rather than newer versions I installed via pip (cmake 3.25.0, pkgconfig 1.5.5).

The CMake version “shouldn’t” matter. Installing a newer one from pip is a waste of time, but shouldn’t make things worse. (Hopefully. It may lack correct system integration.)

There’s no such thing as a pip version of pkg-config. But there is a python module that is a set of thin python functions that run the system pkg-config, translating a python function-y interface into a set of arguments to subprocess.run, then parse the returned output into python lists.

Neither meson nor SciPy uses that, so you can ignore that this wrapper module exists.

…

What matters is if the openblas RHEL package ships with the upstream openblas cmake files. Unfortunately, it doesn’t – for the same reason it doesn’t ship with the upstream openblas pkg-config file.

As @rgommers said, you can write your own – or download openblas yourself and install it by hand, I guess.

Unfortunately there’s nothing to do other than to submit a bug report to RHEL, they broke the upstream software.

I couldn’t find it here: https://scipy.org/install/

That page itself shouldn’t have instructions for building from source, however it does need to link to the correct pages in our developer docs. I’ll fix that.

Mixing conda- and homebrew-installed bits seems to be brittle.

Yes, that is likely to lead to problems. There should never be a need to do this. I guess even considering that is a carry-over of bad habits forced on us by PyPI being so incomplete.

@rgommers

Here’s the result:

$ /usr/bin/pkg-config openblas --cflags
Package openblas was not found in the pkg-config search path.
Perhaps you should add the directory containing `openblas.pc'
to the PKG_CONFIG_PATH environment variable
Package 'openblas', required by 'virtual:world', not found

$ /usr/bin/pkg-config openblas --libs
Package openblas was not found in the pkg-config search path.
Perhaps you should add the directory containing `openblas.pc'
to the PKG_CONFIG_PATH environment variable
Package 'openblas', required by 'virtual:world', not found

$ /usr/bin/pkg-config blas --cflags

$ /usr/bin/pkg-config blas --libs
-lblas

BTW, I found Fedora decided not to ship openblas.pc https://bugzilla.redhat.com/show_bug.cgi?id=1574517

Here’s the discussion in another thread in case you are not aware of: https://github.com/scipy/scipy/pull/16750

gh-16750 improves the fallback detection. I’ve tested that indeed pkg-config gets tried first, and CMake second.

so the issue and solution are more discoverable.

Okay, I edited the title since I guess the Python version is not relevant and maybe numpy isn’t either…

Great, thanks Oscar!

I guess this can be closed then?

I’m expecting the same question a bunch more times, so let’s leave this open for now so the issue and solution are more discoverable.