我从https://pypi.python.org/pypi/PyAudio下载了PyAudio 0.2.11 tar文件并运行以下命令:
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"但在编译时它显示以下错误:
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
答案 0 :(得分:2)
的Python 第一个软件要求是Python 2.6,2.7或Python 3.3+。这是使用库所必需的。
PyAudio(适用于麦克风用户) 当且仅当您想使用麦克风输入(麦克风)时才需要PyAudio。 PyAudio版本0.2.11+是必需的,因为早期版本在某些情况下从麦克风录制时已知存储器管理错误。
如果没有安装,库中的所有内容仍然有效,除了尝试实例化Microphone对象将引发AttributeError。
PyAudio网站上的安装说明非常好 - 为方便起见,它们总结如下:
在Windows上,使用Pip安装PyAudio:在终端中执行pip install pyaudio
。
在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
。
在OS X上,使用Homebrew安装PortAudio:brew install portaudio
。然后,使用Pip安装PyAudio:pip install pyaudio
。
在其他基于POSIX的系统上,使用您选择的软件包管理器安装portaudio19-dev和python-all-dev(或python3-all-dev,如果使用Python 3)软件包(或其最接近的等价物),然后使用Pip安装PyAudio:pip install pyaudio
(如果使用Python 3,则将pip
替换为pip3
。
pip install wheel
,然后运行pip install ./third-party/WHEEL_FILENAME
(如果在存储库根目录中使用Python 3,则将pip
替换为pip3
。
答案 1 :(得分:1)
这对我有用:
sudo pip install --upgrade pyaudio
答案 2 :(得分:1)
你在https://pypi.python.org/pypi/PyAudio#downloads下载PyAudio-0.2.11.tar.gz(md5) 并提取文件。
cd PyAudio-0.2.11
sudo python setup.py install
running install
running bdist_egg
running egg_info
writing src/PyAudio.egg-info/PKG-INFO
writing top-level names to src/PyAudio.egg-info/top_level.txt
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
creating build
creating build/lib.linux-x86_64-2.7
copying src/pyaudio.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/_portaudiomodule.o -lportaudio -o build/lib.linux-x86_64-2.7/_portaudio.so
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_portaudio.so -> build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/pyaudio.py -> build/bdist.linux-x86_64/egg
byte-compiling build/bdist.linux-x86_64/egg/pyaudio.py to pyaudio.pyc
creating stub loader for _portaudio.so
byte-compiling build/bdist.linux-x86_64/egg/_portaudio.py to _portaudio.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying src/PyAudio.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/PyAudio.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/PyAudio.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/PyAudio.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/PyAudio-0.2.11-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing PyAudio-0.2.11-py2.7-linux-x86_64.egg
Copying PyAudio-0.2.11-py2.7-linux-x86_64.egg to /usr/local/lib/python2.7/dist-packages
Adding PyAudio 0.2.11 to easy-install.pth file
Installed /usr/local/lib/python2.7/dist-packages/PyAudio-0.2.11-py2.7-linux-x86_64.egg
Processing dependencies for PyAudio==0.2.11
Finished processing dependencies for PyAudio==0.2.11
答案 3 :(得分:1)
尝试了所有方法。.对我唯一的方法是从https://pypi.org/project/PyAudio/#files下载文件并安装
答案 4 :(得分:1)
只需使用--upgrade标志进行安装。这可能是由于较旧版本的PyAudio不支持的依赖关系所致。
pip install --upgrade pyaudio
这个工人对我来说
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
答案 5 :(得分:0)
sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
sudo apt-get install ffmpeg libav-tools
sudo apt-get install python-pyaudio
来自您的终端
答案 6 :(得分:0)
我也有类似的问题,,,只需升级你的gcc即
sudo apt-get update gcc
首先安装#include<portaudio>
答案 7 :(得分:0)
尝试以下任何一种方法:
pip安装PyAudio
pip3安装PyAudio
python -m pip安装PyAudio
python -m pip3安装PyAudio