如何在 Fedora 上安装 PyAudio 0.2.11

3
我想使用Python的SpeechRecognition库,但是当我尝试运行一个使用麦克风的程序时,我遇到了错误:

"需要PyAudio 0.2.11或更高版本(发现版本0.2.9)"

所以我做了一些调查,并找到了如何使用apt-get安装。不幸的是,我运行的是Fedora 26,因此我必须使用yum来安装我的软件包,当我寻找使用它安装PyAudio的方法时,我只能找到版本0.2.9。

每当我尝试执行

pip install pyaudio

我会得到以下错误:

Failed building wheel for pyaudio 运行setup.py clean for pyaudio 无法构建pyaudio 安装收集的软件包:pyaudio 运行setup.py install for pyaudio ... 错误 命令/usr/bin/python2 -u -c "import setuptools, tokenize;file='/tmp/pip-build-ZiuxD3/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 /tmp/pip-a2Iwxv-record/install-record.txt --single-version-externally-managed --compile的完整输出: 运行安装 运行构建 运行build_py 创建build 创建build/lib.linux-x86_64-2.7 将src/pyaudio.py复制到build/lib.linux-x86_64-2.7 运行build_ext 构建'_portaudio'扩展 创建build/temp.linux-x86_64-2.7 创建build/temp.linux-x86_64-2.7/src gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: 没有那个文件或目录 错误:命令'gcc'失败,退出状态为1
----------------------------------------

命令"/usr/bin/python2 -u -c "import setuptools, tokenize;file='/tmp/pip-build-ZiuxD3/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 /tmp/pip-a2Iwxv-record/install-record.txt --single-version-externally-managed --compile"执行失败,错误代码为1,在/tmp/pip-build-ZiuxD3/pyaudio/中。

2个回答

8
你需要:
sudo dnf install portaudio-devel redhat-rpm-config

接下来,您可以安装pyaudio。
pip install --user pyaudio

注意:

  1. yum已经被弃用,应使用dnf代替。
  2. 当您看到有关程序编译/构建的信息时,请始终检查是否安装了开发依赖项,如package_name-devel。
  3. 在Fedora上使用pip安装时,请始终使用--user。它会将软件包安装在您的主目录中。否则,可能会与dnf软件包发生冲突。

第一步成功了,但是在第二步中我遇到了相同的错误。 - undefined
你首先需要这个:redhat-rpm-config。然而,在此之后,portaudio-devel是必需的。否则,你将会遇到另一个类似的错误。 - undefined
谢谢!它起作用了。我第一次没有看到redhat-rpm-config。 - undefined

1

我也遇到了同样的错误,并尝试在终端中运行以下命令:

sudo dnf install python-pyaudio

在运行上述命令后,为了验证您的pyaudio安装是否成功,请尝试运行以下代码: pip install pyaudio 或者您可以通过以下命令检查以下Python包列表并在其中找到它:pip list

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