简体   繁体   中英

install pyaudio with macOs Sierra

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

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 python3 -B -u -m pip -v install --no-warn-script-location --no-cache-dir --global-option=build_ext --global-option="-I$(brew --prefix portaudio)/include" --global-option="-L$(brew --prefix portaudio)/lib" pyaudio

请尝试以下命令。

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

You can add the directory to your CPATH . Try:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM