LoginSignup
0
0

More than 1 year has passed since last update.

Scipyのビルドでコケた件(Ubuntu, Python3.10)

Last updated at Posted at 2022-11-04

1. 概要

 MKLをリンクしたScipyを使用するためビルドしようとしたら以下のエラーが出たが、openblas-devをインストールしたらビルドに成功した。

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

2. 実行環境

  • Ubuntu 22.04.1 LTS on WSL2
  • Python 3.10.6

3. 内容

 MKLをリンクしたNumpy、Scipyを使用するために、いつも両パッケージをビルドしてインストールしている(参考NumPy/SciPy で Intel MKL を利用する (2019年11月版))。最近Ubuntuのバージョンを20.04から22.04へとアップグレードしたのに伴って、Pythonのバージョンが3.8から3.10に変更された。そこでパッケージをインストールし直していたのだが、Scipyのビルドでエラーが発生したため、その対処法を書き残しておく。

3.1 実行コマンド・エラー出力

(venv310) user@host:~$ pip install scipy
Collecting scipy
  Using cached scipy-1.9.3.tar.gz (42.1 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [67 lines of output]
      The Meson build system
      Version: 0.63.3
      Source dir: /tmp/pip-install-zvhwhcu_/scipy_5691822260404182a10d4f24cb2ebe05
      Build dir: /tmp/pip-install-zvhwhcu_/scipy_5691822260404182a10d4f24cb2ebe05/.mesonpy-ujapjd7b/build
      Build type: native build
      Project name: SciPy
      Project version: 1.9.3
      C compiler for the host machine: cc (gcc 11.3.0 "cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
      C linker for the host machine: cc ld.bfd 2.38
      C++ compiler for the host machine: c++ (gcc 11.3.0 "c++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
      C++ linker for the host machine: c++ ld.bfd 2.38
      Host machine cpu family: x86_64
      Host machine cpu: x86_64
      Compiler for C supports arguments -Wno-unused-but-set-variable: YES
      Compiler for C supports arguments -Wno-unused-but-set-variable: YES (cached)
      Compiler for C supports arguments -Wno-unused-function: YES
      Compiler for C supports arguments -Wno-conversion: YES
      Compiler for C supports arguments -Wno-misleading-indentation: YES
      Compiler for C supports arguments -Wno-incompatible-pointer-types: YES
      Library m found: YES
      Fortran compiler for the host machine: gfortran (gcc 11.3.0 "GNU Fortran (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0")
      Fortran linker for the host machine: gfortran ld.bfd 2.38
      Compiler for Fortran supports arguments -Wno-conversion: YES
      Program cython found: YES (/tmp/pip-build-env-jwrxnkd1/overlay/bin/cython)
      Program pythran found: YES (/tmp/pip-build-env-jwrxnkd1/overlay/bin/pythran)
      Program cp found: YES (/usr/bin/cp)
      Program python found: YES (/home/user/.virtualenvs/venv310/bin/python3)
      Found pkg-config: /usr/bin/pkg-config (0.29.2)
      Run-time dependency threads found: YES
      Library npymath found: YES
      Library npyrandom found: YES
      Found CMake: /usr/bin/cmake (3.22.1)
      Run-time dependency openblas found: NO (tried pkgconfig and cmake)
      Run-time dependency openblas found: NO (tried pkgconfig and cmake)
      
      ../../scipy/meson.build:131:0: ERROR: Dependency "OpenBLAS" not found, tried pkgconfig and cmake
      
      A full log can be found at /tmp/pip-install-zvhwhcu_/scipy_5691822260404182a10d4f24cb2ebe05/.mesonpy-ujapjd7b/build/meson-logs/meson-log.txt
      + meson setup --native-file=/tmp/pip-install-zvhwhcu_/scipy_5691822260404182a10d4f24cb2ebe05/.mesonpy-native-file.ini -Ddebug=false -Doptimization=2 --prefix=/usr /tmp/pip-install-zvhwhcu_/scipy_5691822260404182a10d4f24cb2ebe05 /tmp/pip-install-zvhwhcu_/scipy_5691822260404182a10d4f24cb2ebe05/.mesonpy-ujapjd7b/build
      Traceback (most recent call last):
        File "/home/user/.virtualenvs/venv310/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
          main()
        File "/home/user/.virtualenvs/venv310/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/user/.virtualenvs/venv310/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-jwrxnkd1/overlay/lib/python3.10/site-packages/mesonpy/__init__.py", line 969, in get_requires_for_build_wheel
          with _project(config_settings) as project:
        File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
          return next(self.gen)
        File "/tmp/pip-build-env-jwrxnkd1/overlay/lib/python3.10/site-packages/mesonpy/__init__.py", line 948, in _project
          with Project.with_temp_working_dir(
        File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__
          return next(self.gen)
        File "/tmp/pip-build-env-jwrxnkd1/overlay/lib/python3.10/site-packages/mesonpy/__init__.py", line 777, in with_temp_working_dir
          yield cls(source_dir, tmpdir, build_dir)
        File "/tmp/pip-build-env-jwrxnkd1/overlay/lib/python3.10/site-packages/mesonpy/__init__.py", line 682, in __init__
          self._configure(reconfigure=bool(build_dir) and not native_file_mismatch)
        File "/tmp/pip-build-env-jwrxnkd1/overlay/lib/python3.10/site-packages/mesonpy/__init__.py", line 713, in _configure
          self._meson(
        File "/tmp/pip-build-env-jwrxnkd1/overlay/lib/python3.10/site-packages/mesonpy/__init__.py", line 696, in _meson
          return self._proc('meson', *args)
        File "/tmp/pip-build-env-jwrxnkd1/overlay/lib/python3.10/site-packages/mesonpy/__init__.py", line 691, in _proc
          subprocess.check_call(list(args))
        File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['meson', 'setup', '--native-file=/tmp/pip-install-zvhwhcu_/scipy_5691822260404182a10d4f24cb2ebe05/.mesonpy-native-file.ini', '-Ddebug=false', '-Doptimization=2', '--prefix=/usr', '/tmp/pip-install-zvhwhcu_/scipy_5691822260404182a10d4f24cb2ebe05', '/tmp/pip-install-zvhwhcu_/scipy_5691822260404182a10d4f24cb2ebe05/.mesonpy-ujapjd7b/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.

3.2 解決策

libopenblas-devをインストールする。

user@host:~$ sudo apt install libopenblas-dev

下記ページによるとビルドする際に使うのがnumpy.distutilsからMesonに変更されて、依存関係を探すのがパスのハードコートからpkg-config経由に変わったかららしい。

4. 参考文献

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0