Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to install PyAudio into a VirtualEnv on Mac OS X 10.10

Install portaudio using homebrew (or method of your choice)

brew install portaudio

create $HOME/.pydistutils.cfg using the include and lib directories of your portaudio install:

[build_ext]
include_dirs=/Users/jrobert1271/homebrew/Cellar/portaudio/19.20140130/include/
library_dirs=/Users/jrobert1271/homebrew/Cellar/portaudio/19.20140130/lib/

Then in your virtualenv:

pip install --allow-external pyaudio --allow-unverified pyaudio pyaudio
@ewjoachim

This comment has been minimized.

Copy link

@ewjoachim ewjoachim commented Jul 6, 2015

Thanks !

@rasmi

This comment has been minimized.

Copy link

@rasmi rasmi commented Jul 17, 2015

Thanks!

@karadza3a

This comment has been minimized.

Copy link

@karadza3a karadza3a commented Jan 11, 2016

Make sure you double-check the path in .cfg, mine was "/usr/local/Cellar/portaudio/19.20140130".

@algera

This comment has been minimized.

Copy link

@algera algera commented Jul 7, 2016

💯

@exsurgo

This comment has been minimized.

Copy link

@exsurgo exsurgo commented Sep 19, 2016

Awesome!! Thanks!

@okofish

This comment has been minimized.

Copy link

@okofish okofish commented Nov 16, 2016

👌

@theSetOfR

This comment has been minimized.

Copy link

@theSetOfR theSetOfR commented Nov 30, 2016

perfect!

@abhi18av

This comment has been minimized.

Copy link

@abhi18av abhi18av commented Jan 16, 2017

Hey, on my anaconda-pythn3.5 installation it raised the following warning

DEPRECATION: --allow-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.
DEPRECATION: --allow-unverified has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect.

Regarding my pip version

❯ pip3 --version
pip 9.0.1 from /Users/eklavya/anaconda/lib/python3.5/site-packages (python 3.5)
@cbcafiero

This comment has been minimized.

Copy link

@cbcafiero cbcafiero commented May 26, 2017

If using Macports, tweak the recipe

port install portaudio

create $HOME/.pydistutils.cfg using the include and lib directories of your portaudio install:

[build_ext]
include_dirs=/opt/local/include/
library_dirs=/opt/local/lib/

Then in your virtualenv:

pip install --allow-external pyaudio --allow-unverified pyaudio pyaudio
@jnfran92

This comment has been minimized.

Copy link

@jnfran92 jnfran92 commented May 23, 2018

Great, Thanks !

@ccarstens

This comment has been minimized.

Copy link

@ccarstens ccarstens commented Sep 11, 2019

macOS 10.14.6

This solved it for me:
pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio

@chrislos

This comment has been minimized.

Copy link

@chrislos chrislos commented Feb 25, 2020

@ccarstens Thanks! worked for me!

@RogerChu8

This comment has been minimized.

Copy link

@RogerChu8 RogerChu8 commented Feb 27, 2020

macOS 10.14.6

This solved it for me:
pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio

I tried but got the following error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1

Is this something to do with Xcode installation?

Thanks.
-------- full list of error message below --------

/Users/roger/ml/env/lib/python3.7/site-packages/pip/_internal/commands/install.py:244: UserWarning: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
cmdoptions.check_install_build_global(options)
Collecting pyaudio
Using cached PyAudio-0.2.11.tar.gz (37 kB)
Skipping wheel build for pyaudio, due to binaries being disabled for it.
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
ERROR: Command errored out with exit status 1:
command: /Users/roger/ml/env/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/nj/3sdbvf895vd9s0dtdlyw302r0000gn/T/pip-install-enh0aujj/pyaudio/setup.py'"'"'; file='"'"'/private/var/folders/nj/3sdbvf895vd9s0dtdlyw302r0000gn/T/pip-install-enh0aujj/pyaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' build_ext -I/usr/local/include -L/usr/local/lib install --record /private/var/folders/nj/3sdbvf895vd9s0dtdlyw302r0000gn/T/pip-record-wslhmklz/install-record.txt --single-version-externally-managed --compile --install-headers /Users/roger/ml/env/bin/../include/site/python3.7/pyaudio
cwd: /private/var/folders/nj/3sdbvf895vd9s0dtdlyw302r0000gn/T/pip-install-enh0aujj/pyaudio/
Complete output (8 lines):
running build_ext
building '_portaudio' extension
creating build
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DMACOSX=1 -I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-3.7/src/_portaudiomodule.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/roger/ml/env/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/nj/3sdbvf895vd9s0dtdlyw302r0000gn/T/pip-install-enh0aujj/pyaudio/setup.py'"'"'; file='"'"'/private/var/folders/nj/3sdbvf895vd9s0dtdlyw302r0000gn/T/pip-install-enh0aujj/pyaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' build_ext -I/usr/local/include -L/usr/local/lib install --record /private/var/folders/nj/3sdbvf895vd9s0dtdlyw302r0000gn/T/pip-record-wslhmklz/install-record.txt --single-version-externally-managed --compile --install-headers /Users/roger/ml/env/bin/../include/site/python3.7/pyaudio Check the logs for full command output.

@mcorderoaraya

This comment has been minimized.

Copy link

@mcorderoaraya mcorderoaraya commented Aug 11, 2020

python3 -m easy_install pyobjc

@Mattia541993

This comment has been minimized.

Copy link

@Mattia541993 Mattia541993 commented Oct 8, 2020

macOS 10.14.6

This solved it for me:
pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio

This worked for me Mac 10.15.5. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment