pyaudioがinstallできない
環境
macOS Big Sur ver. 11.5.1(20G80) -> 12.6 (21G115)
MacBook Air M1, 2020
8GB
Homebreq ver.3.6.3(git revision 86ac48865b7; last commit 2022-10-02)
Python 3.10.6
pip 22.2.2 from /opt/homebrew/lib/python3.10/site-packages/pip (python 3.10)
怒られ内容
MacBook-Air ~ % pip3 install pyaudio
Collecting pyaudio
Using cached PyAudio-0.2.12.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
Error in sitecustomize; set PYTHONVERBOSE for traceback:
AssertionError:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-11-arm64-cpython-310
copying src/pyaudio.py -> build/lib.macosx-11-arm64-cpython-310
running build_ext
building '_portaudio' extension
creating build/temp.macosx-11-arm64-cpython-310
creating build/temp.macosx-11-arm64-cpython-310/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -DMACOSX=1 -I/usr/local/include -I/usr/include -I/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c src/_portaudiomodule.c -o build/temp.macosx-11-arm64-cpython-310/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects
なんかpyproject.tomlをinstallしろって言われてる.
pyproject.tomlってなに…
一旦こいつが何かは置いといてエラー文で検索かけたら
sudo apt install portaudio19-dev
なんかこれをやるとできるようになることがあるらしい.
といってもaptはLinuxのコマンドだからmacOSでは
brew install portaudio19-dev
にすればいいんだろうか.
とりあえずやってみよう.
MacBook-Air ~ % brew install portaudio19-dev
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
jj netcdf-cxx rome
mycorrhiza netcdf-fortran tbls
You have 3 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.
==> Tapping homebrew/cask
Cloning into '/opt/homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 675808, done.
remote: Counting objects: 100% (19/19), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 675808 (delta 8), reused 9 (delta 0), pack-reused 675789
Receiving objects: 100% (675808/675808), 320.53 MiB | 6.26 MiB/s, done.
Resolving deltas: 100% (479579/479579), done.
Tapped 4083 casks (4,155 files, 342MB).
Warning: No available formula with the name "portaudio19-dev". Did you mean portaudio?
==> Searching for similarly named formulae...
This similarly named formula was found:
portaudio ✔
To install it, run:
brew install portaudio ✔
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
怒られちゃった…。
わからなかったから質問したら,次のサイトを進められた.
って書いてあったけど..pydistutils.cfgファイルはまだHOME(ターミナルで"~"で表示されるディレクトリ)になかったので新たに作って
[build_ext]
include_dirs=/opt/homebrew/include
library_dirs=/opt/homebrew/lib
書いた後にpip3 install pyaudioしたら
MacBook-Air ~ % pip3 install pyaudio
Collecting pyaudio
Using cached PyAudio-0.2.12.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... done
Created wheel for pyaudio: filename=PyAudio-0.2.12-cp310-cp310-macosx_11_0_arm64.whl size=25307 sha256=86131303537a5ee6ed19cf27b52f2f77602f48a9cd6d67b1b33e64e2f40b9e62
Stored in directory: /Users/usrname/Library/Caches/pip/wheels/eb/71/06/030b8fdda053802be6a3c6b13b39bb7cb1bd196d9459b6e0f9
Successfully built pyaudio
Installing collected packages: pyaudio
Successfully installed pyaudio-0.2.12
できた!!