when installing pyaudio, pip cannot find portaudio

2019-01-13 04:50发布

I'm using mac osx 10.10 As the PyAudio Homepage said, I install the PyAudio using

brew install portaudio 
pip install pyaudio

the installation of portaudio seems successful, I can find headers and libs in /usr/local/include and /usr/local/lib but when I try to install pyaudio, it gives me an error that

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

actually it is in /usr/local/include why can't it find the file? some answers to similar questions are not working for me(like using virtualenv, or compile it manually), and I want to find a simple way to solve this.

8条回答
贼婆χ
2楼-- · 2019-01-13 04:51

on Centos:

yum install -y portaudio portaudio-devel && pip install pyaudio
查看更多
放我归山
3楼-- · 2019-01-13 04:52

On Raspbian:

sudo apt-get install python-pyaudio
查看更多
祖国的老花朵
4楼-- · 2019-01-13 04:54

On Ubuntu builds:

sudo apt-get install python-pyaudio

For Python3:

sudo apt-get install python3-pyaudio
查看更多
爷、活的狠高调
5楼-- · 2019-01-13 05:01

You have to install portaudio first then link that file. Only then you can find that header file (i.e, portaudio.h). To install portaudio in mac by using HomeBrew program use following commands.

brew install portaudio
sudo brew link portaudio
sudo pip install pyaudio
查看更多
兄弟一词,经得起流年.
6楼-- · 2019-01-13 05:04

First you can use brew to install portaudio .

brew install portaudio

Then try to find the portaudio path sudo find / -name "portaudio.h"

In my case it is /usr/local/Cellar/portaudio/19.6.0/include .

Run the below to install pyaudio

pip install --global-option='build_ext' --global-option='-I/usr/local/Cellar/portaudio/19.6.0/include' --global-option='-L/usr/local/Cellar/portaudio/19.6.0/lib' pyaudio

查看更多
来,给爷笑一个
7楼-- · 2019-01-13 05:06

Just for the record for folks using MacPorts and not Homebrew:

$ [sudo] port install portaudio
$ pip install pyaudio --global-option="build_ext"  --global-option="-I/opt/local/include" --global-option="-L/opt/local/lib"
查看更多
登录 后发表回答