PyAudio 在 Mac 上安装总是失败 [英] PyAudio installation always fails on Mac

查看:123
本文介绍了PyAudio 在 Mac 上安装总是失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我尝试过

pip install pyaudio

但是那没有用...我发现我需要 PortAudio,所以用 brew 安装它:

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

brew install portaudio

成功了,然后我重新启动了我的 Mac.

That worked and then I restarted my Mac.

但是 pip install pyaudio 仍然不起作用,我收到以下错误消息:

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

错误:命令出错,退出状态为 1:命令:/Applications/Xcode.app/Contents/Developer/usr/bin/python3 -u -c'导入系统、设置工具、标记化;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(标记化,'"'"'open'""'"', open)(文件);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-gvmpobvycwd:/private/var/folders/12/44t6pktj77xbqmyp7x368tdr0000gn/T/pip-install-gvxfbjmp/pyaudio/完整输出(16 行):运行 bdist_wheel运行构建运行 build_py创建构建创建 build/lib.macosx-10.14-x86_64-3.7复制 src/pyaudio.py ->构建/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/srcxcrun -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/私人头文件-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.osrc/_portaudiomodule.c:29:10: 致命错误:找不到portaudio.h"文件#include portaudio.h"^~~~~~~~~~~~~产生了 1 个错误.错误:命令xcrun"失败,退出状态为 1---------------------------错误:pyaudio 的构建轮失败

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

我也试过 pip3 install pyaudio 没有任何运气.

I also tried pip3 install pyaudio without any luck.

顺便说一句,我这样做是因为我想使用 Python Speech Recognition API 并且我认为 pyaudio 是必要的......是吗?

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

推荐答案

您很可能需要指定编译器可以在其中找到诸如 portaudio.h 之类的源程序的目录路径.

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

假设标题位于 /usr/local/include 目录中,尝试在终端中运行以下命令:

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

这篇关于PyAudio 在 Mac 上安装总是失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆