Ich versuche, pyaudio mit pip zu installieren:
pip install pyaudio
In einer virtualenv bekomme ich aber einen Fehler:
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Gesamte Ausgabe:
Collecting pyaudio
Using cached PyAudio-0.2.9.tar.gz
Building wheels for collected packages: pyaudio
Running setup.py bdist_wheel for pyaudio ... error
Complete output from command /home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-GCltlv/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpyR6J73pip-wheel- --python-tag cp27:
running bdist_wheel
running build
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 -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
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
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 /home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-GCltlv/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-icMIUV-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/include/site/python2.7/pyaudio:
running install
running build
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 -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
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-GCltlv/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-icMIUV-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/include/site/python2.7/pyaudio" failed with error code 1 in /tmp/pip-build-GCltlv/pyaudio
Was mache ich falsch? Ich bin neu in Virtualenvs.
* Ich kann andere Pakete installieren. Ich habe nur einen Fehler für pyaudio-Paket.
Übrigens bin ich in der Umgebung:
(ENV) [email protected]:~/Downloads/VirtualEnvironment/vir1/MyProject$
Einige Pakete erfordern die Unterstützung von Nicht-Python-Software, z. B. gemeinsam genutzte Bibliotheken. Diese können können nicht über pip installiert werden (sie sind keine Python-Pakete!). Sie installieren diese auf dem Host normalerweise mit dem Paketmanager Ihres Hosts (apt-get
oder yum
oder dnf
usw.) oder Sie verwenden etwas wie Docker, um sowohl die Abhängigkeiten als auch Ihre Anwendung zu kapseln.
In Ihrem Fall benötigt pyaudio eine Reihe von Bibliotheken, darunter mindestens portaudio
. Sie müssen die entsprechenden Entwicklungspakete auf Ihrem System installieren, wie in den Kommentaren zu Ihrer Frage vorgeschlagen.
Das hat für mich funktioniert, ich hatte das gleiche Problem:
wenn Sie PyAudio in einer virtuellen Umgebung installieren möchten, installieren Sie die PortAudio-Entwicklungsheader von APT und dann PyAudio:
Sudo apt-get install portaudio19-dev
pip install --allow-unverified=pyaudio pyaudio
Die folgenden Schritte haben für mich funktioniert :) Bitte gehen Sie durch und probieren Sie es aus
1 Sudo apt-get install libasound-dev
2 Sudo apt-get install portaudio19-dev
3 pip install pyaudio --user
ODER (--user funktioniert nicht, dann probiere python3-pyaudio)
Sudo apt-get install python3-pyaudio
In neuem Python 3.0 kann pyaudio unter Windows folgenden Befehl installieren: Pip3 install pyaudio.
Wenn Sie pyaudio in einer virtuellen Umgebung unter Windows installieren möchten, müssen Sie zuerst PyAudio-0.2.11-cp37-cp37m-win_AMD64.whl herunterladen. Diese Datei finden Sie in [ https://www.lfd.uci.edu/~ gohlke/pythonlibs /] Öffnen Sie hier den Befehl Prompt und gehen Sie zu dem Pfad, in dem sich Ihre heruntergeladene Datei befindet, und geben Sie pip install PyAudio-0.2.11-cp37-cp37m-win_AMD64.whl ein