実現したいこと
pyaudioのインストール
前提
M1 mac
pyaudioをインストールしたいのですが、最新のpythonには対応していないとあったので以下の方法でインストールを試してみました。しかし、以下のような同じエラーメッセージが出ます。
https://qiita.com/ninomium/items/20507e48541a4b3a1859
https://www.youtube.com/watch?v=vcyAeKy9TCA
https://moromisenpy.com/pyaudio/#M1_Mac%E3%81%A7%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB
Collecting pyaudio Using cached PyAudio-0.2.13.tar.gz (46 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 ╰─> [15 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-x86_64-cpython-38 creating build/lib.macosx-10.9-x86_64-cpython-38/pyaudio copying src/pyaudio/__init__.py -> build/lib.macosx-10.9-x86_64-cpython-38/pyaudio running build_ext building 'pyaudio._portaudio' extension creating build/temp.macosx-10.9-x86_64-cpython-38 creating build/temp.macosx-10.9-x86_64-cpython-38/src creating build/temp.macosx-10.9-x86_64-cpython-38/src/pyaudio gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/Caskroom/miniforge/base/envs/ds_env/include -arch x86_64 -I/usr/local/Caskroom/miniforge/base/envs/ds_env/include -arch x86_64 -DMACOS=1 -I/usr/local/include -I/usr/include -I/opt/homebrew/include "-I<PATH FROM STEP 3>/include/" -I/usr/local/Caskroom/miniforge/base/envs/ds_env/include/python3.8 -c src/pyaudio/device_api.c -o build/temp.macosx-10.9-x86_64-cpython-38/src/pyaudio/device_api.o xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun error: command '/usr/bin/gcc' 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 Note: you may need to restart the kernel to use updated packages.
どのように解決すれば良いでしょうか?
「あなたが参考にしたページ」ではなくて「あなたがやったこと」を書いてください。回答するのに必要なのは「あなたがやったこと」の情報です。あなたが参考にしたページは、あなたの問題を解決する役には立ちません(参考にはなりますが)。
OSのバージョン、Pythonのバージョン(どうやってインストールしたものか)も書いてあった方がいいです。
> 最新のpythonには対応していないとあったので
もどういうことか分かりませんでした。どういう意味ですか?
> M1 mac
なのに、エラーメッセージの
> creating build/lib.macosx-10.9-x86_64-cpython-38
とかには「x86_64」とあります
もしかして、rosettaを使ってintel用のpythonを使ってて、そこにインストールしたいのでしょうか?
もしそうなら、
brew install portaudio
で入れたのはarm用だったりしませんでしょうか?
https://pypi.org/project/PyAudio/
の
Use Homebrew to install the prerequisite portaudio library, then install PyAudio using pip:
brew install portaudio
pip install pyaudio
の通り、M1 MacでApple Silicon用のHomebrewとApple Silicon用のPythonを使っている限り、難しい要素はまったくなく素直に入りました。
pyaudioに関する情報はすべて余計で、
PythonとHomebrewについて、rosettaを使ってIntelバイナリをわざわざつかっているのか? Pythonはどこから入手してどうインストールしたものか? などなど
の「自身の環境を説明できること」が一番大事で必要なことです。

あなたの回答
tips
プレビュー