install pyaudio with macOs Sierra

落花浮王杯 提交于 2019-12-22 08:05:44

问题


I upgraded my Mac to macOS Sierra and I had to start a new account. Right now I am trying to establish my environment. I ran into a problem installing pyaudio. The procedure I used is first use homebrew and install port audio.

brew install portaudio

It installs with no errors.

I proceed to install pyaudio using pip

pip install pyaudio

I receive the following error message.

cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DMACOSX=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/_portaudiomodule.c -o build/temp.macosx-10.12-intel-2.7/src/_portaudiomodule.o
src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
         ^
1 error generated.
error: command 'cc' failed with exit status 1

portaudio.h is available in  /usr/local/Cellar/portaudio/19.20140130/include

I am unfamiliar with pip and don't know how to pass the path to the complier.

Any help will be greatly appreciated.

thanks

Rod


回答1:


Thanks for the suggestion. I tried it but it did not work. It seems pip is not finding both include files and libraries when attempting to install in macOS Sierra

I did some digging into how to pass paths with pip and I successfully installed pyaudio using the following command.

sudo pip -v install --global-option=build_ext --global-option="-I/usr/local/Cellar/portaudio/19.20140130/include" --global-option="-L/usr/local/opt/portaudio/lib" pyaudio



回答2:


Please try the command below.

sudo CPATH="$CPATH:/usr/local/include" LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" pip install pyaudio



回答3:


You can add the directory to your CPATH. Try:

CPATH="$CPATH:/usr/local/Cellar/portaudio/19.20140130/include"
pip install pyaudio


来源:https://stackoverflow.com/questions/41333908/install-pyaudio-with-macos-sierra

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