个性化阅读
专注于IT技术分析

如何解决Ubuntu 18.04中PyAudio的安装错误(严重错误:找不到”portaudio.h”文件)

本文概述

通常, 你将能够使用以下命令通过PIP安装PyAudio:

pip install PyAudio

遗憾的是, 在某些Ubuntu发行版中, 构建pyaudio轮子时会遇到失败的例外情况。根据Python包装索引的描述, 转盘*旨在以与磁盘格式非常接近的方式包含与PEP 376兼容安装的所有文件。

错误

当你尝试安装软件包时, 错误输出将是:

pip install pyaudio
Failed building wheel for pyaudio
  Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio
  Running setup.py install for pyaudio ... error
    Complete output from command /Users/kj/Desktop/ml/gui/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/vd/8zl261fj35j8pst5659glmjc0000gn/T/pip-build-gj9ny3f9/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 /var/folders/vd/8zl261fj35j8pst5659glmjc0000gn/T/pip-45sl0b3v-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/kj/Desktop/ml/gui/include/site/python3.6/pyaudio:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.12-x86_64-3.6
    copying src/pyaudio.py -> build/lib.macosx-10.12-x86_64-3.6
    running build_ext
    building '_portaudio' extension
    creating build/temp.macosx-10.12-x86_64-3.6
    creating build/temp.macosx-10.12-x86_64-3.6/src
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DMACOSX=1 -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/Users/kj/Desktop/ml/gui/include -I/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/_portaudiomodule.c -o build/temp.macosx-10.12-x86_64-3.6/src/_portaudiomodule.o
    src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
    #include "portaudio.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1

该错误基本上是由系统中缺少portaudio.h文件引起的。 PortAudio是一个免费的, 跨平台的开源音频I / O库。

你可以使用以下命令在Ubuntu中安装dev portaudio软件包和pyaudio来解决此异常:

sudo apt-get install portaudio19-dev python-pyaudio

最后, 使用以下命令再次安装该软件包:

pip install PyAudio

而且你应该能够正确安装它而不会出现问题!

编码愉快!

赞(0)
未经允许不得转载:srcmini » 如何解决Ubuntu 18.04中PyAudio的安装错误(严重错误:找不到”portaudio.h”文件)

评论 抢沙发

评论前必须登录!