1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

M1 MacでScipyが入らないときにやったこと

Last updated at Posted at 2023-05-25

M1 Macでpyenv環境を作成してもろもろライブラリをインストールしようとしたところ、scipyが入らない。
scipyが入らないとscikit-learnが入らないので致命的。
※ pyenvではpythonバージョンを3.9.16としている

エラーメッセージ

Collecting scipy
  Using cached scipy-1.10.1.tar.gz (42.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [40 lines of output]
      The Meson build system
      Version: 1.1.0
      Source dir: /private/var/folders/5_/kwy7fv5j6n1_4jsf8xmgtdkr0000gn/T/pip-install-butlt1cb/scipy_4e7a7a2084554d13b7700b0a3e7a5b7e
      Build dir: /private/var/folders/5_/kwy7fv5j6n1_4jsf8xmgtdkr0000gn/T/pip-install-butlt1cb/scipy_4e7a7a2084554d13b7700b0a3e7a5b7e/.mesonpy-8f_j0aem/build
      Build type: native build
      Project name: SciPy
      Project version: 1.10.1
      C compiler for the host machine: cc (clang 12.0.5 "Apple clang version 12.0.5 (clang-1205.0.22.11)")
      C linker for the host machine: cc ld64 650.9
      C++ compiler for the host machine: c++ (clang 12.0.5 "Apple clang version 12.0.5 (clang-1205.0.22.11)")
      C++ linker for the host machine: c++ ld64 650.9
      Cython compiler for the host machine: cython (cython 0.29.35)
      Host machine cpu family: aarch64
      Host machine cpu: aarch64
      Compiler for C supports arguments -Wno-unused-but-set-variable: NO
      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 13.1.0 "GNU Fortran (Homebrew GCC 13.1.0) 13.1.0")
      Fortran linker for the host machine: gfortran ld64 650.9
      Compiler for Fortran supports arguments -Wno-conversion: YES
      Checking if "-Wl,--version-script" : links: NO
      Program cython found: YES (/private/var/folders/5_/kwy7fv5j6n1_4jsf8xmgtdkr0000gn/T/pip-build-env-m33zcgb8/overlay/bin/cython)
      Program python found: YES (/Users/<username>/.pyenv/versions/3.9.16/bin/python3.9)
      Found pkg-config: /opt/homebrew/bin/pkg-config (0.29.2)
      Program pythran found: YES (/private/var/folders/5_/kwy7fv5j6n1_4jsf8xmgtdkr0000gn/T/pip-build-env-m33zcgb8/overlay/bin/pythran)
      Run-time dependency threads found: YES
      Library npymath found: YES
      Library npyrandom found: YES
      Found CMake: /opt/homebrew/bin/cmake (3.26.4)
      WARNING: CMake Toolchain: Failed to determine CMake compilers state
      Run-time dependency openblas found: NO (tried pkgconfig, framework and cmake)
      Run-time dependency openblas found: NO (tried pkgconfig, framework and cmake)

      ../../scipy/meson.build:134:7: ERROR: Dependency "OpenBLAS" not found, tried pkgconfig, framework and cmake

      A full log can be found at /private/var/folders/5_/kwy7fv5j6n1_4jsf8xmgtdkr0000gn/T/pip-install-butlt1cb/scipy_4e7a7a2084554d13b7700b0a3e7a5b7e/.mesonpy-8f_j0aem/build/meson-logs/meson-log.txt
      + meson setup --prefix=/Users/<username>/.pyenv/versions/3.9.16 /private/var/folders/5_/kwy7fv5j6n1_4jsf8xmgtdkr0000gn/T/pip-install-butlt1cb/scipy_4e7a7a2084554d13b7700b0a3e7a5b7e /private/var/folders/5_/kwy7fv5j6n1_4jsf8xmgtdkr0000gn/T/pip-install-butlt1cb/scipy_4e7a7a2084554d13b7700b0a3e7a5b7e/.mesonpy-8f_j0aem/build --native-file=/private/var/folders/5_/kwy7fv5j6n1_4jsf8xmgtdkr0000gn/T/pip-install-butlt1cb/scipy_4e7a7a2084554d13b7700b0a3e7a5b7e/.mesonpy-native-file.ini -Ddebug=false -Doptimization=2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

解決策

  1. homebrewでOpenBLASインストール
  2. ほか必要ライブラリをインストール
  3. 環境変数を指定してscipy v1.7.0をpip install
brew install openblas
pip install cython pybind11 pythran numpy
OPENBLAS=$(brew --prefix openblas) CFLAGS="-falign-functions=8 ${CFLAGS}" pip install --no-use-pep517 scipy==1.7.0

参考:https://github.com/scipy/scipy/issues/13409#issue-790703815

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?