- I installed brew
- Use brew install portaudio
- I link with brew link portaudio
- Installed pyaudio with 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
and I tried install with pip install pyaudio and pip3 install pyaudio
But unhappily I always have the same error
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-12-arm64-cpython-310
copying src/pyaudio.py -> build/lib.macosx-12-arm64-cpython-310
running build_ext
building '_portaudio' extension
creating build/temp.macosx-12-arm64-cpython-310
creating build/temp.macosx-12-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/MacOSX12.sdk -DMACOSX=1 -I/usr/local/include -I/usr/include -I</opt/homebrew/opt/portaudi>include/ -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c src/_portaudiomodule.c -o build/temp.macosx-12-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
CodePudding user response:
I have the same issue as well, but following work-around worked for me.
- Install portaudio
brew install portaudio
- Link
brew link portaudio
- Locate the library and includes
sudo find / -name "portaudio.h"
- Use it with global options
pip3 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
But this fails as you are pointing above. For some reason, it doesn't include the path for libs and include with build_ext
option.
Downloading PyAudio-0.2.12.tar.gz (42 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.9/42.9 kB 1.6 MB/s eta 0:00:00
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
╰─> [16 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-11.0-arm64-cpython-39
copying src/pyaudio.py -> build/lib.macosx-11.0-arm64-cpython-39
running build_ext
building '_portaudio' extension
creating build/temp.macosx-11.0-arm64-cpython-39
creating build/temp.macosx-11.0-arm64-cpython-39/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/koteshk/miniforge3/include -arch arm64 -fPIC -O2 -isystem /Users/koteshk/miniforge3/include -arch arm64 -DMACOSX=1 -I/usr/local/include -I/usr/include -I/Users/koteshk/miniforge3/include/python3.9 -c src/_portaudiomodule.c -o build/temp.macosx-11.0-arm64-cpython-39/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]
- Work around
Manually copy the libs and include files to one of the system paths. Note you may have to create the directory if it's not present.
sudo cp -r /opt/homebrew/Cellar/portaudio/19.7.0/include/* /usr/local/include
sudo cp -r /opt/homebrew/Cellar/portaudio/19.7.0/lib/* /usr/local/lib
- Install pyaudio
pip install pyaudio
CodePudding user response:
OK, I solved my own problem. To solved this problem portaudio.h just follow the topics bellow.
Pyaudio for MACOS users --> Project with Speech Recognition
- Install homebrew --> https://brew.sh/index_pt-br
brew install portaudio
brew link portaudio
- type
LDFLAGS="-L$(brew --prefix portaudio)/lib" CFLAGS="-I$(brew --prefix portaudio)/include" pip install pyaudio
brew install flac
--> https://formulae.brew.sh/formula/flac- install speech_recognition with pip