首先,我尝试了
pip install pyaudio
但那行不通...我发现我需要PortAudio,于是我使用brew
进行了安装:
brew install portaudio
这个方法起作用了,然后我重新启动了我的Mac。
但是pip install pyaudio
仍然不起作用,我收到以下错误信息:
错误:命令以退出状态1结束: 命令:/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/ 完整输出(16行): 运行 bdist_wheel 运行 build 运行 build_py 创建 build creating build/lib.macosx-10.14-x86_64-3.7 copying src/pyaudio.py -> build/lib.macosx-10.14-x86_64-3.7 运行build_ext 构建 '_portaudio' 扩展 创建 build/temp.macosx-10.14-x86_64-3.7 创建 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: 致命错误:未找到 'portaudio.h' 文件 #include "portaudio.h" ^~~~~~~~~~~~~ 1个错误已生成。 错误:命令‘xcrun’执行失败,退出状态为1
我尝试了pip3 install pyaudio
,但没有成功。
顺便说一下,我这么做只是因为我想使用Python语音识别API,而我认为pyaudio
是必需的...是吗?
pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio
https://dev59.com/-1wX5IYBdhLWcg3wrRE5 - tjallo