无法安装pyaudio,gcc错误

36
尝试按照指示在此处安装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

我的安装出了什么问题?


8
gcc找不到PortAudio头文件,你是否安装了PortAudio开发包(例如,对于Ubuntu可以使用apt-get install libportaudio-dev安装)? 另外需要注意的是,在Ubuntu中,至少对于Python 2和3来说,pyaudio已经在软件库中了,可以通过apt-get install python(3)-pyaudio进行安装。 - l4mpi
1
那个有效,我会接受它作为答案,谢谢! - Mittenchops
1
可能存在重复发布:https://dev59.com/5Oo6XIcBkEYKwwoYTSou?rq=1 - Paul
对我有用的是Cerin在AI_ROBOT答案中的评论。正在使用Ubuntu 20.04.3 LTS。 - YoussefDir
16个回答

0

0

在经过长时间搜索后,我解决了PyAudio错误。

希望这能帮助到某些人。

首先,您需要查找Python版本,使用命令:python --version(检查Pycharm和JupyterLab,因为我有3.7.6和3.10.4不同的版本,并移动到正确的目录-我将相同版本的whl文件粘贴到同一目录中,“可能还有其他方法-欢迎提出建议”)

一旦将该文件放置在相同的目录下-"PyAudio-0.2.11-cp37-cp37m-win_amd64.whl",则可以直接使用pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl安装。

其他发现:

如果版本和文件不匹配,则会收到此错误:

ERROR: PyAudio-0.2.11-cp310-cp310-win32.whl不支持此平台。

简单的"pip install pyaudio"将无法工作(据在互联网上读到的,它无法在3.6以上版本中工作)


0
在Manjaro(Arch Linux)上,使用以下命令安装python-pyaudio:sudo pacman -S python-pyaudio

0

在将pyaudio工作在阿尔派Linux容器(python:3.9-alpine)中的过程中,我遇到了这个问题。

在这种情况下,需要安装一些额外的软件包。 我会发布我必须做的内容,以防对某人有用。

apk add --no-cache py3-pyaudio portaudio-dev gcc musl-dev
pip install pyaudio

安装pyaudio需要gcc和musl-dev包中包含的dev文件。


-1

免责声明 - 适用于Linux终端命令

  1. 运行 pip install wheel
  2. 下载此文件夹中的内容 https://github.com/Uberi/speech_recognition
  3. 运行 pip install ./third-party/WHEEL_FILENAME,在这里选择你的WHEEL文件 https://github.com/Uberi/speech_recognition/tree/master/third-party

我的是 (Linux) - PyAudio-0.2.11.tar.gz

最后运行: pip install ./third-party/PyAudio-0.2.11.tar.gz (如果使用Python 3,请将 pip 替换为 pip3)


-3
尝试运行以下命令pip install PyAudio

欢迎来到SO!这个解决方案已经在几个答案中提到过(例如:https://dev59.com/ps_B0IgBFxS5KdRjCuWR#57947026)。 - Sergey Shubin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接