Before I start the question, I tried to solve issue with this post, but it did not work: (Link)
I am using mac (M1 air).
I tried to install pyaudio, so I ran pip install pyaudio
.
Then, I got the following error about not finding portaudio.h:
pip 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 wheel metadata ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /Users/sunwoojeong/anaconda3/bin/python /Users/sunwoojeong/anaconda3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/jm/hwnp4x291qd9n0vw1p4kzw_m0000gn/T/tmpzv_dfxv_
cwd: /private/var/folders/jm/hwnp4x291qd9n0vw1p4kzw_m0000gn/T/pip-install-y3rg1882/pyaudio_1d880ef087ea42298d89af097d6745ed
Complete output (16 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-cpython-38
copying src/pyaudio.py -> build/lib.macosx-10.9-x86_64-cpython-38
running build_ext
building '_portaudio' extension
creating build/temp.macosx-10.9-x86_64-cpython-38
creating build/temp.macosx-10.9-x86_64-cpython-38/src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/sunwoojeong/anaconda3/include -arch x86_64 -I/Users/sunwoojeong/anaconda3/include -arch x86_64 -DMACOSX=1 -I/usr/local/include -I/usr/include -I/Users/sunwoojeong/anaconda3/include/python3.8 -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-cpython-38/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/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio which use PEP 517 and cannot be installed directly
So, After some research I tried to install and link portaudio first like this:
brew install portaudio
brew link portaudio
pip install pyaudio
Since brew link portaudio
returns Warning: Already linked: /opt/homebrew/Cellar/portaudio/19.7.0
, I expected that portaudio was installed succesfully and pyaudio should have no issue with portaudio.h file. However, even after installing it, and after explicitly setting the path to the portaudio folder, the pip install command still returns this error.
Here is the pip commands I tried (they all return the same error):
pip install pyaudio
pip install --global-option='build_ext' --global-option="-I$(brew --prefix)/include" --global-option="-L$(brew --prefix)/lib" pyaudio
pip install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio
Has anyone had similar issue and solved it before when installing a python module with some c-lang file?