question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: Cannot install SciPy using pip on Raspberry Pi

See original GitHub issue

Describe your issue.

Tried to install scipy through pip3 install -3 requirements.txt with the following: librosa==0.6.3 numpy pandas soundfile==0.9.0 wave scikit-learn==0.24.2 tqdm==4.28.1 matplotlib==2.2.3 pyaudio==0.2.11 but it gave an error. Already tried using sudo apt-get install python3-scipy, but still the same issue happens.

Reproducing Code Example

N/A - all I did is run sudo LLVM_CONFIG=`which llvm-config-11` pip3 install -r requirements.txt

Error message

Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [55 lines of output]
      The Meson build system
      Version: 0.62.2
      Source dir: /tmp/pip-install-93y57wnw/scipy_34185744f91f4e619985e97d31e27821
      Build dir: /tmp/pip-install-93y57wnw/scipy_34185744f91f4e619985e97d31e27821/.mesonpy-b9th5ncm/build
      Build type: native build
      Project name: SciPy
      Project version: 1.9.0
      C compiler for the host machine: cc (gcc 8.3.0 "cc (Raspbian 8.3.0-6+rpi1) 8.3.0")
      C linker for the host machine: cc ld.bfd 2.31.1
      C++ compiler for the host machine: c++ (gcc 8.3.0 "c++ (Raspbian 8.3.0-6+rpi1) 8.3.0")
      C++ linker for the host machine: c++ ld.bfd 2.31.1
      Host machine cpu family: arm
      Host machine cpu: armv7l
      Compiler for C supports arguments -Wno-unused-but-set-variable: YES
      Library m found: YES
      Fortran compiler for the host machine: gfortran (gcc 8.3.0 "GNU Fortran (Raspbian 8.3.0-6+rpi1) 8.3.0")
      Fortran linker for the host machine: gfortran ld.bfd 2.31.1
      Program cython found: YES (/tmp/pip-build-env-wco6m20p/overlay/bin/cython)
      Program pythran found: YES (/tmp/pip-build-env-wco6m20p/overlay/bin/pythran)
      Program cp found: YES (/usr/bin/cp)
      Program python3 found: YES (/usr/local/bin/python3.9)
      Found pkg-config: /usr/bin/pkg-config (0.29)
      
      ../../scipy/meson.build:40:0: ERROR: Command "/usr/local/bin/python3.9 -c import os; os.chdir(".."); import numpy; print(numpy.get_include())" failed with status 1.
      
      A full log can be found at /tmp/pip-install-93y57wnw/scipy_34185744f91f4e619985e97d31e27821/.mesonpy-b9th5ncm/build/meson-logs/meson-log.txt
      + meson setup --native-file=/tmp/pip-install-93y57wnw/scipy_34185744f91f4e619985e97d31e27821/.mesonpy-native-file.ini -Ddebug=false -Doptimization=2 --prefix=/usr/local /tmp/pip-install-93y57wnw/scipy_34185744f91f4e619985e97d31e27821 /tmp/pip-install-93y57wnw/scipy_34185744f91f4e619985e97d31e27821/.mesonpy-b9th5ncm/build
      Traceback (most recent call last):
        File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/usr/local/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 "/usr/local/lib/python3.9/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-wco6m20p/overlay/lib/python3.9/site-packages/mesonpy/__init__.py", line 909, in get_requires_for_build_wheel
          with _project(config_settings) as project:
        File "/usr/local/lib/python3.9/contextlib.py", line 119, in __enter__
          return next(self.gen)
        File "/tmp/pip-build-env-wco6m20p/overlay/lib/python3.9/site-packages/mesonpy/__init__.py", line 888, in _project
          with Project.with_temp_working_dir(
        File "/usr/local/lib/python3.9/contextlib.py", line 119, in __enter__
          return next(self.gen)
        File "/tmp/pip-build-env-wco6m20p/overlay/lib/python3.9/site-packages/mesonpy/__init__.py", line 547, in with_temp_working_dir
          yield cls(source_dir, tmpdir, build_dir)
        File "/tmp/pip-build-env-wco6m20p/overlay/lib/python3.9/site-packages/mesonpy/__init__.py", line 463, in __init__
          self._configure(reconfigure=bool(build_dir) and not native_file_mismatch)
        File "/tmp/pip-build-env-wco6m20p/overlay/lib/python3.9/site-packages/mesonpy/__init__.py", line 494, in _configure
          self._meson(
        File "/tmp/pip-build-env-wco6m20p/overlay/lib/python3.9/site-packages/mesonpy/__init__.py", line 477, in _meson
          return self._proc('meson', *args)
        File "/tmp/pip-build-env-wco6m20p/overlay/lib/python3.9/site-packages/mesonpy/__init__.py", line 472, in _proc
          subprocess.check_call(list(args))
        File "/usr/local/lib/python3.9/subprocess.py", line 373, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['meson', 'setup', '--native-file=/tmp/pip-install-93y57wnw/scipy_34185744f91f4e619985e97d31e27821/.mesonpy-native-file.ini', '-Ddebug=false', '-Doptimization=2', '--prefix=/usr/local', '/tmp/pip-install-93y57wnw/scipy_34185744f91f4e619985e97d31e27821', '/tmp/pip-install-93y57wnw/scipy_34185744f91f4e619985e97d31e27821/.mesonpy-b9th5ncm/build']' returned non-zero exit status 1.
      [end of output]

SciPy/NumPy/Python version information

Python 3.9 - NumPy 1.22.4

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rekkitcwtscommented, Aug 6, 2022

Just a thought, but looking at that meson log, this is a Raspberry Pi, right? The compiler toolchain seems to suggest that, and it would be consistent with a bunch of source build failures because compatible binaries may not be available on default PyPI.

If my guess is right, you might try something like https://www.raspberrypi.com/news/piwheels/ perhaps? To check maybe do uname -m and let us know what it says? I think Pi boards use something other than the ARMv8/aarch64 that we support/provide binaries for? @rgommers or @h-vetinari may know better than I.

Yep – it’s a raspberry pi 3b+ with Buster in it – and it fixed itself when I downgraded the Python from 3.9 to 3.7 due to some “glibc” errors.

0reactions
yumemiocommented, Dec 20, 2022

Thanks @rgommers, and sorry for replying late. The Meson log revealed the actual issue: libcblas.so.3 was missing.

$ pip install --config-settings=builddir=/home/me/scipy/build scipy==1.9.3
...
$ cat scipy/build/meson-logs/meson-log.txt
...
(truncated)
...
Run-time dependency threads found: YES
Running command: /usr/bin/python3 -c import os; os.chdir(".."); import numpy; print(numpy.get_include())
--- stdout ---

--- stderr ---
Traceback (most recent call last):
  File "/tmp/pip-build-env-y7tf5n1e/overlay/lib/python3.9/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/tmp/pip-build-env-y7tf5n1e/overlay/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/tmp/pip-build-env-y7tf5n1e/overlay/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

...
(truncated)
...

I have uploaded the complete log without truncation here for reference.

After running apt install libatlas-base-dev (as described in this StackOverflow answer), scipy==1.9.3 was installed successfully.

Therefore the complete installation process for RPi4 would be:

# apt install gfortran cmake libopenblas-base libopenblas-dev libatlas-base-dev
$ pip install scipy==1.9.3
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't install scipy to Raspberry pi 4 (raspbian) - Stack Overflow
I am trying to install the scipy library with python3 -m pip install --user --no-use-pep517 scipy but I am receiving the following error:...
Read more >
How to install latest Scipy version on Raspberry Pi
The main reason is that scipy relies on compiled C and fortran libraries, that need to be compiled on the same architecture. Usually...
Read more >
Installing Scipy - Raspberry Pi Forums
I am new to raspberry and python and I have a few questions that need. ... to install using the command $ sudo...
Read more >
Installing scipy on raspberry pi 4 error · Issue #77 - GitHub
Running from scipy source directory. /tmp/pip-build-env-hwix6duo/lib/python3. 7/site-packages/numpy/distutils/system_info. py:624: UserWarning:
Read more >
Installing scikit-learn
There are different ways to install scikit-learn: Install the latest official release. This is the best approach for most users. It will provide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found