简体   繁体   English

无法安装pyaudio,gcc错误

[英]Cannot install pyaudio, gcc error

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?我的安装出了什么问题?

Sorry about the inappropriate answer last time, I will post the solution of the question.抱歉上次回答不当,我会发布问题的解决方案。 It might be helpful for Ubuntu distributions.它可能对 Ubuntu 发行版有帮助。

  1. First we need to install portaudio modules: sudo apt-get install libasound-dev首先我们需要安装 portaudio 模块: sudo apt-get install libasound-dev

  2. Download the portaudio archive from: http://files.portaudio.com/download.html从以下网址下载 portaudio 存档:http: //files.portaudio.com/download.html

  3. Unzip the archive: tar -zxvf [portaudio.tgz]解压存档: tar -zxvf [portaudio.tgz]

  4. Enter the directory, then run: ./configure && make进入目录,然后运行: ./configure && make

  5. Install: sudo make install安装: sudo make install

  6. And finally: sudo pip install pyaudio最后: sudo pip install pyaudio

  7. Check the version of pyaudio, it should be 0.2.9检查pyaudio的版本,应该是0.2.9

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

On Ubuntu:在 Ubuntu 上:

sudo apt-get install python-pyaudio

or或者

sudo apt-get install python3-pyaudio

Install 2 things,安装2个东西,

sudo apt-get install portaudio19-dev python-pyaudio

and then,接着,

pip install pyaudio

For Centos7:对于 Centos7:

sudo yum install -y portaudio-devel
sudo pip install pyaudio

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 Homebrew to install the prerequisite portaudio library, then install PyAudio using pip:使用Homebrew安装必备的 portaudio 库,然后使用 pip 安装 PyAudio:

 brew install portaudio
 pip install pyaudio

pip will download the PyAudio source 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 包索引 (PyPI) 下载:这里!

Or clone the git repository:或者克隆 git 存储库:

git clone https://people.csail.mit.edu/hubert/git/pyaudio.git

credits: PyAudio and GitHub:Speech_Recognition学分: PyAudioGitHub:Speech_Recognition

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?我的安装出了什么问题?

  • First we need to install portaudio modules: sudo apt-get install libasound-dev首先我们需要安装 portaudio 模块: sudo apt-get install libasound-dev

  • Download the portaudio archive from: http://portaudio.com/download.html从以下网址下载 portaudio 存档:http: //portaudio.com/download.html

  • Unzip the archive: tar -zxvf [portaudio.tgz]解压存档: tar -zxvf [portaudio.tgz]

  • Enter the directory, then run: ./configure && make进入目录,然后运行: ./configure && make

  • Install: sudo make install安装: sudo make install

  • And Then: sudo pip install pyaudio然后: sudo pip install pyaudio

  • Update & Upgrade the system to fix all broken libraries更新和升级系统以修复所有损坏的库

  • sudo apt update && sudo apt upgrade

sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
sudo apt-get install ffmpeg# libav-tools
sudo pip install pyaudio

as sayantan ghosh told (in my case, it's error with libav-tools) and正如 sayantan ghosh 所说(在我的情况下,这是 libav-tools 的错误)和

sudo apt-get install python3-pyaudio

as Aaron told, then pip install pyaudio正如 Aaron 所说,然后 pip install pyaudio

these steps works for me, Im in ubuntu 20.04这些步骤对我有用,我在 ubuntu 20.04

I am using kali linux 2.0, do as follows:我使用的是kali linux 2.0,执行如下:

apt-get install portaudio19-dev python-pyaudio

then:然后:

pip install pyaudio

this worked for me.这对我有用。

Download PyAudio from the link below: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio Then, install this file using the command:从以下链接下载 PyAudio: https ://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio 然后,使用以下命令安装此文件:

pip install (complete filepath)

Example:例子:

pip install C:\Users\(Username)\Downloads\PyAudio-0.2.11-cp39-cp39-win_amd64.whl

Disclaimer - For Linux terminal command免责声明 - 适用于 Linux 终端命令

  1. Run pip install wheel运行pip install wheel
  2. Download this https://github.com/Uberi/speech_recognition Inside above-mentioned folder下载这个https://github.com/Uberi/speech_recognition在上述文件夹中
  3. Run pip install ./third-party/WHEEL_FILENAME Here Choose your WHEEL from https://github.com/Uberi/speech_recognition/tree/master/third-party在此处运行pip install ./third-party/WHEEL_FILENAMEhttps://github.com/Uberi/speech_recognition/tree/master/third-party中选择您的 WHEEL

mine was (Linux) - PyAudio-0.2.11.tar.gz我的是(Linux) - PyAudio-0.2.11.tar.gz

Then Finally Run: pip install ./third-party/PyAudio-0.2.11.tar.gz (replace pip with pip3 if using Python 3)然后最后运行: pip install ./third-party/PyAudio-0.2.11.tar.gz (如果使用 Python 3,请将pip替换为pip3

在 Manjaro(Arch Linux)上sudo pacman -S python-pyaudio

I came across this question while getting pyaudio working in an alpine linux container (python:3.9-alpine).我在让 pyaudio 在 alpine linux 容器(python:3.9-alpine)中工作时遇到了这个问题。

There were some additional packages to install in this case.在这种情况下,需要安装一些额外的软件包。 I'll post what I had to do in case it's useful for someone.我会发布我必须做的事情,以防它对某人有用。

apk add --no-cache py3-pyaudio portaudio-dev gcc musl-dev
pip install pyaudio

The pyaudio pip install needs gcc and also the dev files included in musl-dev package. pyaudio pip install 需要 gcc 以及 musl-dev 包中包含的 dev 文件。

I could resolved PyAudio error after a long search经过长时间的搜索,我可以解决 PyAudio 错误

Hope this can help someone.希望这可以帮助某人。

First you find the python version using : python --version (check both Pycharm and JupyterLab as I had 3.7.6 and 3.10.4 different version and move to correct directory - I pasted the same version whl file in same directory "may be there is another way of doing it - suggestions welcome" )首先,您使用以下命令找到 python 版本:python --version (检查 Pycharm 和 JupyterLab,因为我有 3.7.6 和 3.10.4 不同的版本并移动到正确的目录 - 我将相同版本的 whl 文件粘贴到同一目录中“可能在那里是另一种方式 - 欢迎提出建议”)

Once this file is placed in the same directory - " PyAudio-0.2.11-cp37-cp37m-win_amd64.whl " you can use pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl directly一旦这个文件被放在同一个目录 - “ PyAudio-0.2.11-cp37-cp37m-win_amd64.whl ” 你可以直接使用pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl

Other findings :其他发现:

In case the version and file not matching you will get this error如果版本和文件不匹配,您将收到此错误

ERROR: PyAudio-0.2.11-cp310-cp310-win32.whl is not a supported wheel on this platform.错误:PyAudio-0.2.11-cp310-cp310-win32.whl 不是该平台支持的滚轮。

simple " pip install pyaudio " will not work (As read on internet its not working beyond 3.6)简单的“ pip install pyaudio ”将不起作用(正如在互联网上阅读的那样,它在 3.6 之后不起作用)

this is work for me这对我有用

sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0

After that run this command之后运行这个命令

pip install pyaudio --user

试试这个命令 pip install PyAudio

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM