PyAudio installation always fails on Mac

匆匆过客 提交于 2021-02-10 14:48:41

问题


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?


回答1:


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



回答2:


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


来源:https://stackoverflow.com/questions/62751582/pyaudio-installation-always-fails-on-mac

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!