无法在 ubuntu 16.04 中安装 PyAudio 0.2.11 [英] Cannot install PyAudio 0.2.11 in ubuntu 16.04

查看:104
本文介绍了无法在 ubuntu 16.04 中安装 PyAudio 0.2.11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 https://pypi.python.org/pypi/下载了 PyAudio 0.2.11 tar 文件PyAudio 并运行以下命令:

I downloaded PyAudio 0.2.11 tar file from https://pypi.python.org/pypi/PyAudio and run the following command:

sudo python setup.py install

我收到以下错误:

running install

Checking .pth file support in /usr/local/lib/python3.5/dist-packages/
/usr/bin/python3 -E -c pass

TEST PASSED: /usr/local/lib/python3.5/dist-packages/ appears to support .pth files

running bdist_egg

running egg_info

writing top-level names to src/PyAudio.egg-info/top_level.txt

writing src/PyAudio.egg-info/PKG-INFO

writing dependency_links to src/PyAudio.egg-info/dependency_links.txt

reading manifest file 'src/PyAudio.egg-info/SOURCES.txt'

reading manifest template 'MANIFEST.in'

writing manifest file 'src/PyAudio.egg-info/SOURCES.txt'

installing library code to build/bdist.linux-x86_64/egg

running install_lib

running build_py

running build_ext

building '_portaudio' extension

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.5/src/_portaudiomodule.o
src/_portaudiomodule.c:28:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

如何才能成功安装?

我什至尝试过这个git clone https://people.csail.mit.edu/hubert/git/pyaudio.git",但在编译时显示以下错误:

I even tried this "git clone https://people.csail.mit.edu/hubert/git/pyaudio.git" but at the time of compilation it shows the following error:

src/_portaudiomodule.c:28:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

为了编译我使用了这个命令:sudo python3 setup.py install

To compile I used this command: sudo python3 setup.py install

推荐答案

Python第一个软件要求是 Python 2.6、2.7 或 Python 3.3+.这是使用库所必需的.

Python The first software requirement is Python 2.6, 2.7, or Python 3.3+. This is required to use the library.

PyAudio(适用于麦克风用户)当且仅当您想使用麦克风输入(麦克风)时,才需要 PyAudio.需要 PyAudio 0.2.11+ 版本,因为早期版本在某些情况下从麦克风录音时已知内存管理错误.

PyAudio (for microphone users) PyAudio is required if and only if you want to use microphone input (Microphone). PyAudio version 0.2.11+ is required, as earlier versions have known memory management bugs when recording from microphones in certain situations.

如果未安装,库中的所有内容仍然有效,除非尝试实例化 Microphone 对象会引发 AttributeError.

If not installed, everything in the library will still work, except attempting to instantiate a Microphone object will raise an AttributeError.

PyAudio 网站上的安装说明相当不错——为方便起见,总结如下:

The installation instructions on the PyAudio website are quite good - for convenience, they are summarized below:

在 Windows 上,使用 Pip 安装 PyAudio:在终端中执行 pip install pyaudio.

On Windows, install PyAudio using Pip: execute pip install pyaudio in a terminal.

在源自 Debian 的 Linux 发行版(如 Ubuntu 和 Mint)上,使用 APT 安装 PyAudio:在终端中执行 sudo apt-get install python-pyaudio python3-pyaudio.如果存储库中的版本太旧,请使用 Pip 安装最新版本:执行 sudo apt-get install portaudio19-dev python-all-dev python3-all-dev &&sudo pip install pyaudio(如果使用 Python 3,请将 pip 替换为 pip3).

On Debian-derived Linux distributions (like Ubuntu and Mint), install PyAudio using APT: execute sudo apt-get install python-pyaudio python3-pyaudio in a terminal. If the version in the repositories is too old, install the latest release using Pip: execute sudo apt-get install portaudio19-dev python-all-dev python3-all-dev && sudo pip install pyaudio (replace pip with pip3 if using Python 3).

在 OS X 上,使用 Homebrew 安装 PortAudio:brew install portaudio.然后,使用 Pip 安装 PyAudio:pip install pyaudio.

On OS X, install PortAudio using Homebrew: brew install portaudio. Then, install PyAudio using Pip: pip install pyaudio.

在其他基于 POSIX 的系统上,使用您选择的包管理器安装 portaudio19-dev 和 python-all-dev(或 python3-all-dev,如果使用 Python 3)包(或它们最接近的等价物),然后使用 Pip 安装 PyAudio:pip install pyaudio(如果使用 Python 3,请将 pip 替换为 pip3).

On other POSIX-based systems, install the portaudio19-dev and python-all-dev (or python3-all-dev if using Python 3) packages (or their closest equivalents) using a package manager of your choice, and then install PyAudio using Pip: pip install pyaudio (replace pip with pip3 if using Python 3).

为方便起见,包含了适用于 Windows 和 Linux 上常见 64 位 Python 版本的 PyAudio 轮包,位于存储库根目录的第三方/目录下.要安装,只需运行 pip install wheel 后跟 pip install ./third-party/WHEEL_FILENAME(用 pip3 替换 pipcode> 如果使用 Python 3) 在存储库根目录中.

PyAudio wheel packages for common 64-bit Python versions on Windows and Linux are included for convenience, under the third-party/ directory in the repository root. To install, simply run pip install wheel followed by pip install ./third-party/WHEEL_FILENAME (replace pip with pip3 if using Python 3) in the repository root directory.

这篇关于无法在 ubuntu 16.04 中安装 PyAudio 0.2.11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆