如何安装 PyAudio 0.2.11 Fedora

K. *_*ans 1 python speech-recognition fedora pyaudio

我想使用 Python 的 SpeechRecognition 库,但是当我尝试运行一个使用麦克风的程序时,我打算这样做,我收到错误

“需要 PyAudio 0.2.11 或更高版本(找到版本 0.2.9)”

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

每当我尝试做

pip 安装 pyaudio

我收到以下错误:

pyaudio 的构建轮失败运行 setup.py clean for pyaudio 无法构建 pyaudio 安装收集的包:pyaudio 运行 setup.py install for pyaudio ...错误命令 /usr/bin/python2 -u -c "import setuptools,标记化;文件='/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: running install running build running build_py 创建构建创建构建/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 -安全 -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:错误:/usr /lib/rpm/redhat/redhat-hardened-cc1:没有这样的文件或目录错误:命令“gcc”失败,退出状态为 1失败,退出状态为 1失败,退出状态为 1

----------------------------------------
Run Code Online (Sandbox Code Playgroud)

命令“/usr/bin/python2 -u -c”导入设置工具,标记化;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/

Eri*_*ran 6

你需要:

sudo dnf install portaudio-devel redhat-rpm-config
Run Code Online (Sandbox Code Playgroud)

接下来,您可以安装pyaudio。

pip install --user pyaudio
Run Code Online (Sandbox Code Playgroud)

笔记:

  1. yum 已弃用,请改用 dnf。
  2. 当您看到有关程序的编译/构建时,请始终检查您是否具有诸如 package_name-devel 之类的开发依赖项。
  3. 在 Fedora 上使用 pip 安装时,请始终使用 --user。它将在您的家中安装软件包。否则,您可能会与 dnf 包产生冲突。