When Can’t Install pyaudio with pip

0𝕏koji
2 min readMay 20, 2018

--

pip is easy to use, but somtimes it never allows us to install some libraries even though follow the description of the official website.

pip install pyaudioFailed building wheel for pyaudio
Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /Users/kj/Desktop/ml/gui/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/vd/8zl261fj35j8pst5659glmjc0000gn/T/pip-build-gj9ny3f9/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/vd/8zl261fj35j8pst5659glmjc0000gn/T/pip-45sl0b3v-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/kj/Desktop/ml/gui/include/site/python3.6/pyaudio:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.12-x86_64-3.6
copying src/pyaudio.py -> build/lib.macosx-10.12-x86_64-3.6
running build_ext
building '_portaudio' extension
creating build/temp.macosx-10.12-x86_64-3.6
creating build/temp.macosx-10.12-x86_64-3.6/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DMACOSX=1 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/Users/kj/Desktop/ml/gui/include -I/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/_portaudiomodule.c -o build/temp.macosx-10.12-x86_64-3.6/src/_portaudiomodule.o
src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1

Solution

brew update
brew install portaudio
brew link --overwrite portaudio
$ pip install pyaudio
Collecting pyaudio
Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Building wheels for collected packages: pyaudio
Running setup.py bdist_wheel for pyaudio ... done
Stored in directory: /Users/kj/Library/Caches/pip/wheels/f4/a8/a4/292214166c2917890f85b2f72a8e5f13e1ffa527c4200dcede
Successfully built pyaudio
Installing collected packages: pyaudio
Successfully installed pyaudio-0.2.11

However, when you do “brew update”, you need to care about your environment because updating Homebrew sometimes fuck up everything…

Update (2/8/2019)
I just tested pip install on Catalina.

virtual env with python 3.6. There is no issue on installing pyaudio

pip install pyaudio Collecting pyaudio
Downloading https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (setup.py) … done
Created wheel for pyaudio: filename=PyAudio-0.2.11-cp36-cp36m-macosx_10_13_x86_64.whl size=23306 sha256=4b7709748d3492911120e92fd5460d01994d612d009a9d0d8b48a6e301df1e19
Stored in directory: /Users/koji.kanao/Library/Caches/pip/wheels/f4/a8/a4/292214166c2917890f85b2f72a8e5f13e1ffa527c4200dcede
Successfully built pyaudio
Installing collected packages: pyaudio
Successfully installed pyaudio-0.2.11

--

--

0𝕏koji

software engineer works for a Biotechnology Research startup in Brooklyn. #CreativeCoding #Art #IoT #MachineLearning #python #typescript #javascript #reactjs