In my quest to avoid install Homebrew or MacPorts, I ended up with the following steps to install pyaudio using pip
1. Place my a binary of PortAudio in /usr/local/lib. This is the 2016 ‘stable’ version v190600_20161030 that Homebrew still appears to use as well. I didn’t try compiling it from scratch as it requires Mac SDK 10.9 or older.
2. My binary was compiled on another system, and had the wrong LC_ID_DYLIB path. To correct that I did: sudo install_name_tool -id /usr/local/lib/libportaudio.dylib /usr/local/lib/libportaudio.dylib
.
3. Place the corresponding pa_mac_core.h in /usr/local/include
4. Upgrade pip: sudo pip install --upgrade pip
5. Install PyAudio: sudo pip install --global-option=build_ext --global-option=-L/usr/local/lib --global-option=-I/usr/local/include pyaudio
.
Thanks to Stack Overflow for pointing me to the global-option pip flags. Like another user I wondered why pip wouldn’t pick up /usr/local for dependencies by default.
https://stackoverflow.com/questions/33513522/when-installing-pyaudio-pip-cannot-find-portaudio-h-in-usr-local-include
Thanks also to author of the following, which was useful in reading up on the relevant parts of the Mac dynamic linker:
View at Medium.com