3

Firstly, I tried

pip install pyaudio

But that didn't work... I found that I need PortAudio, so installed it with brew:

brew install portaudio

That worked and then I restarted my Mac.

But pip install pyaudio still doesn't work and I get the below error message:

ERROR: Command errored out with exit status 1: command: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/12/44t6pktj77xbqmyp7x368tdr0000gn/T/pip-install-gvxfbjmp/pyaudio/setup.py'"'"'; file='"'"'/private/var/folders/12/44t6pktj77xbqmyp7x368tdr0000gn/T/pip-install-gvxfbjmp/pyaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/12/44t6pktj77xbqmyp7x368tdr0000gn/T/pip-wheel-gvmpobvy cwd: /private/var/folders/12/44t6pktj77xbqmyp7x368tdr0000gn/T/pip-install-gvxfbjmp/pyaudio/ Complete output (16 lines): running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.14-x86_64-3.7 copying src/pyaudio.py -> build/lib.macosx-10.14-x86_64-3.7 running build_ext building '_portaudio' extension creating build/temp.macosx-10.14-x86_64-3.7 creating build/temp.macosx-10.14-x86_64-3.7/src xcrun -sdk macosx clang -arch x86_64 -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Headers -DMACOSX=1 -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/include/python3.7m -c src/_portaudiomodule.c -o build/temp.macosx-10.14-x86_64-3.7/src/_portaudiomodule.o src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found #include "portaudio.h" ^~~~~~~~~~~~~ 1 error generated. error: command 'xcrun' failed with exit status 1 ---------------------------------------- ERROR: Failed building wheel for pyaudio

I also tried pip3 install pyaudio without any luck.

BTW I am just doing this because I want to use the Python Speech Recognition API and I think pyaudio is necessary... is it?

Kate Orlova
  • 3,225
  • 5
  • 11
  • 35
JGStyle
  • 147
  • 12
  • Have you tried this specific answer already? `pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio` https://stackoverflow.com/questions/33513522/when-installing-pyaudio-pip-cannot-find-portaudio-h-in-usr-local-include – tjallo Jul 06 '20 at 07:59

3 Answers3

3

Very likely you need to specify the directory path where the compiler can find the source programs like portaudio.h.

Under assumption that the headers are in /usr/local/include directory, try to run the below command in the Terminal:

pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio
Kate Orlova
  • 3,225
  • 5
  • 11
  • 35
1

your problem is that with the Xcode command-line. Reinstall using this

xcode-select --install

after xcode is fixed the command('xcrun') should be able to run so just reuse

pip3 install pyaudio
Seaver Olson
  • 450
  • 3
  • 16
0

you may need to upgrade pip python3 -m pip install --upgrade pip

-- Successfully installed pip-21.2.4

and/or invoke pip3 pip3 install ...

user3325025
  • 654
  • 7
  • 10