Python 无法安装 pyaudio,gcc 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20023131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot install pyaudio, gcc error
提问by Mittenchops
Trying to install pyaudio with instructions per here:
尝试按照此处的说明安装 pyaudio :
$ git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
$ cd pyaudio
$ sudo python setup.py install
running install
running build
running build_py
running build_ext
building '_portaudio' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o
In file included from /usr/include/python2.7/Python.h:8:0,
from src/_portaudiomodule.c:28:
/usr/include/python2.7/pyconfig.h:1161:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default]
/usr/include/features.h:215:0: note: this is the location of the previous definition
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
What's going wrong in my installation?
我的安装出了什么问题?
回答by AI_ROBOT
Sorry about the inappropriate answer last time, I will post the solution of the question. It might be helpful for Ubuntu distributions.
抱歉上次回答不当,我会发布问题的解决方案。它可能对 Ubuntu 发行版有所帮助。
First we need to install portaudio modules:
sudo apt-get install libasound-devDownload the portaudio archive from: http://portaudio.com/download.html
Unzip the archive:
tar -zxvf [portaudio.tgz]Enter the directory, then run:
./configure && makeInstall:
sudo make installAnd finally:
sudo pip install pyaudioCheck the version of pyaudio, it should be
0.2.9
首先我们需要安装portaudio模块:
sudo apt-get install libasound-dev从以下位置下载 portaudio 档案:http: //portaudio.com/download.html
解压存档:
tar -zxvf [portaudio.tgz]进入目录,然后运行:
./configure && make安装:
sudo make install最后:
sudo pip install pyaudio检查pyaudio的版本,应该是
0.2.9
回答by Aaron
On Ubuntu:
在 Ubuntu 上:
sudo apt-get install python-pyaudio
or
或者
sudo apt-get install python3-pyaudio
回答by sayantan ghosh
This worked for me:
这对我有用:
sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
sudo apt-get install ffmpeg libav-tools
sudo pip install pyaudio
回答by Vitaliy
For Centos7:
对于 Centos7:
sudo yum install -y portaudio-devel
sudo pip install pyaudio
回答by Sindhukumari P
- First we need to install portaudio modules: sudo apt-get install libasound-dev
Download the portaudio archive from: http://portaudio.com/download.html
Unzip the archive:
tar -zxvf [portaudio.tgz]Enter the directory, then run:
./configure && makeInstall:
sudo make installAnd finally:
sudo pip install pyaudioCheck the version of pyaudio, it should be 0.2.9
- 首先我们需要安装portaudio模块:sudo apt-get install libasound-dev
从以下位置下载 portaudio 档案:http: //portaudio.com/download.html
解压存档:
tar -zxvf [portaudio.tgz]进入目录,然后运行:
./configure && make安装:
sudo make install最后:
sudo pip install pyaudio检查pyaudio的版本,应该是0.2.9
回答by Harish Kumawat
step1:
第1步:
sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
step 2:-
第2步:-
pip install pyaudio --user
回答by Imran
For Windows :
对于 Windows:
Install using pip:
使用pip安装:
python -m pip install pyaudio
if pip is not already bundled with your installation of Python, get it here.
如果 pip 尚未与您的 Python 安装捆绑在一起,请在此处获取。
For Mac OS X :
对于 Mac OS X:
Use Homebrewto install the prerequisite portaudio library, then install PyAudio using pip:
使用Homebrew安装必备的 portaudio 库,然后使用 pip 安装 PyAudio:
brew install portaudio
pip install pyaudio
pip will download the PyAudiosource and build it for your version of Python.
pip 将下载PyAudio源代码并为您的 Python 版本构建它。
For Debian/Ubuntu :
对于 Debian/Ubuntu :
Use the package manager to install PyAudio:
使用包管理器安装PyAudio:
sudo apt-get install python-pyaudio python3-pyaudio
If the latest version of PyAudio is not available, install it using pip:
如果最新版本的 PyAudio 不可用,请使用 pip 安装它:
pip install pyaudio
For better isolation from system packages, consider installing PyAudio in a virtual environment
为了更好地与系统包隔离,请考虑在虚拟环境中安装 PyAudio
PyAudio Source :
PyAudio 来源:
Source is available for download at the Python Package Index (PyPI): here!
源代码可从 Python Package Index (PyPI) 下载:这里!
Or clone the git repository:
或者克隆 git 存储库:
git clone https://people.csail.mit.edu/hubert/git/pyaudio.git
credits: PyAudioand GitHub:Speech_Recognition
回答by Mohideen bin Mohammed
Install 2 things,
安装 2 件事,
sudo apt-get install portaudio19-dev python-pyaudio
and then,
进而,
pip install pyaudio

