Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 535
Charles Rodney Gallant Avatar asked Feb 05 '23 11:02

Charles Rodney Gallant


2 Answers

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
like image 121
Charles Rodney Gallant Avatar answered Feb 08 '23 15:02

Charles Rodney Gallant


Please try the command below.

sudo CPATH="$CPATH:/usr/local/include" LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" pip install pyaudio
like image 30
Noriyoshi Kamado Avatar answered Feb 08 '23 15:02

Noriyoshi Kamado