简体   繁体   中英

Installing pyaudio with pip in a virtualenv

I'm trying to install pyaudio with pip:

pip install pyaudio

In a virtualenv but I'm getting an error:

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

Entire output:

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

What am I doing wrong? I'm new in virtualenvs.

*I'm able to install other packages. I'm facing with an error only for pyaudio package.

By the way I'm in the environment:

(ENV) mertyildiran@Corsair:~/Downloads/VirtualEnvironment/vir1/MyProject$

This worked for me, I had the same problem:

if you want to install PyAudio inside a virtualenv, install the PortAudio development headers from APT, then PyAudio:

sudo apt-get install portaudio19-dev
pip install --allow-unverified=pyaudio pyaudio

https://pyspotify.mopidy.com/en/latest/api/sink/

Some packages require the support of non-Python software, such as shared libraries. These cannot be installed via pip (they're not Python packages!). You generally install these on the host using your host's package manager ( apt-get or yum or dnf , etc...), or you use something like Docker to encapsulate both the dependencies and your application.

In your case, pyaudio requires a number of libraries, including at least portaudio . You will need to install the appropriate development packages on your system, as suggested in the comments on your question.

Following steps worked for me :) Please go through and try

1  sudo apt-get install libasound-dev
2  sudo apt-get install portaudio19-dev
3  pip install pyaudio --user

OR (--user dont work then try python3-pyaudio)

sudo apt-get install python3-pyaudio

在新的Python 3.0中,pyaudio可以在windows中安装使用以下命令:pip3 install pyaudio。

如果你想首先在windows中的虚拟环境中安装pyaudio,你需要在[ https://www.lfd.uci.edu/~gohlke/pythonlibs/下载PyAudio-0.2.11-cp37-cp37m-win_amd64.whl这个文件]在这里然后打开命令提示符并转到下载文件所在的路径并输入pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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