无法安装pyaudio,gcc错误

时间:2013-11-16 20:01:27

标签: python pyaudio

尝试使用说明per here安装pyaudio:

$ git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
$ cd pyaudio
$ sudo python setup.py install
running install
running build
running build_py
running build_ext
building '_portaudio' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o
In file included from /usr/include/python2.7/Python.h:8:0,
                 from src/_portaudiomodule.c:28:
/usr/include/python2.7/pyconfig.h:1161:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default]
/usr/include/features.h:215:0: note: this is the location of the previous definition
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

我的安装出了什么问题?

11 个答案:

答案 0 :(得分:22)

对于上次不恰当的回答感到抱歉,我会发布问题的解决方案。它可能对Ubuntu发行版有帮助。

  1. 首先我们需要安装portaudio模块:sudo apt-get install libasound-dev

  2. 从以下网址下载portaudio存档:http://portaudio.com/download.html

  3. 解压缩档案:tar -zxvf [portaudio.tgz]

  4. 输入目录,然后运行:./configure && make

  5. 安装:sudo make install

  6. 最后:sudo pip install pyaudio

  7. 检查pyaudio的版本,它应该是0.2.9

答案 1 :(得分:11)

在Ubuntu上:

sudo apt-get install python-pyaudio

sudo apt-get install python3-pyaudio

答案 2 :(得分:9)

这对我有用:

sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
sudo apt-get install ffmpeg libav-tools
sudo pip install pyaudio

答案 3 :(得分:2)

对于Centos7:

sudo yum install -y portaudio-devel
sudo pip install pyaudio

答案 4 :(得分:2)

对于Windows:

使用pip安装:

 python -m pip install pyaudio

如果您的Python安装尚未捆绑pip,请获取here

对于Mac OS X:

使用Homebrew安装必备的portaudio库,然后使用pip安装PyAudio:

 brew install portaudio
 pip install pyaudio

pip将下载PyAudio源,并为您的Python版本构建它。

对于Debian / Ubuntu:

使用程序包管理器安装PyAudio

 sudo apt-get install python-pyaudio python3-pyaudio

如果没有最新版本的PyAudio,请使用pip安装它:

pip install pyaudio

为了更好地与系统软件包隔离,请考虑在虚拟环境中安装PyAudio

PyAudio来源:

可从Python软件包索引(PyPI)下载源:here!

或克隆git存储库:

git clone https://people.csail.mit.edu/hubert/git/pyaudio.git

积分:PyAudioGitHub:Speech_Recognition

答案 5 :(得分:1)

第1步:

sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0

步骤2:-

pip install pyaudio --user

答案 6 :(得分:0)

  • 首先,我们需要安装portaudio模块:sudo apt-get install libasound-dev
  • 从以下位置下载portaudio存档: http://portaudio.com/download.html

  • 解压缩归档文件:tar -zxvf [portaudio.tgz]

  • 输入目录,然后运行:./configure && make

  • 安装:sudo make install

  • 最后:sudo pip install pyaudio

  • 检查pyaudio的版本,应为0.2.9

答案 7 :(得分:0)

安装2件东西,

sudo apt-get install portaudio19-dev python-pyaudio

然后

pip install pyaudio

答案 8 :(得分:0)

我正在使用kali linux 2.0,请执行以下操作:

apt-get install portaudio19-dev python-pyaudio

然后:

pip install pyaudio

这对我有用。

答案 9 :(得分:0)

从以下链接下载 PyAudio: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio 然后,使用以下命令安装此文件:

pip install (complete filepath)

示例:

pip install C:\Users\(Username)\Downloads\PyAudio-0.2.11-cp39-cp39-win_amd64.whl

答案 10 :(得分:-1)

尝试此命令pip install PyAudio