2016-02-29 26 views
10

Tôi đang cố gắng để cài đặt pyaudio với pip:Cài đặt pyaudio với pip trong một virtualenv

pip install pyaudio 

Trong một virtualenv nhưng tôi nhận được một lỗi:

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

Toàn bộ sản lượng:

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 

Tôi đang làm gì sai? Tôi mới trong virtualenvs.

* Tôi có thể cài đặt các gói khác. Tôi đang phải đối mặt với một lỗi chỉ cho gói pyaudio.

Bằng cách này tôi đang ở trong môi trường:

(ENV) [email protected]:~/Downloads/VirtualEnvironment/vir1/MyProject$ 
+1

nếu bạn đang sử dụng ubuntu 'sudo apt-get cài đặt libasound-dev' - http://portaudio.com/docs/v19-doxydocs/compile_linux.html – dm03514

+0

Tôi đang trong gói virtualenv có lẽ gói này chưa được cài đặt virtualenv. Làm thế nào tôi có thể cài đặt gói này vào virtualenv? Thông thường tôi có thể cài đặt pyaudio từ pip. Nhưng tôi đang ở trong virtualenv. – mertyildiran

+0

@ dm03514 Mặt khác là có cách để cài đặt chỉ bằng pip. Bởi vì tôi đang chuẩn bị một gói để phân phối. – mertyildiran

Trả lời

9

Một số gói đòi hỏi sự hỗ trợ của phần mềm không Python, chẳng hạn như các thư viện chia sẻ. Các không thể được cài đặt qua pip (chúng không phải là gói Python!). Bạn thường cài đặt các trên máy chủ bằng cách sử dụng trình quản lý gói của máy chủ lưu trữ của bạn (apt-get hoặc yum hoặc dnf, v.v ...) hoặc bạn sử dụng một cái gì đó như Docker để gói gọn cả phụ thuộc và ứng dụng của bạn.

Trong trường hợp của bạn, pyaudio yêu cầu một số thư viện, bao gồm ít nhất portaudio. Bạn sẽ cần phải cài đặt các gói phát triển thích hợp trên hệ thống của mình, như được đề xuất trong các nhận xét về câu hỏi của bạn.

+0

Tại sao có một gói cho pyaudio sau đó? https://pypi.python.org/pypi/PyAudio – mertyildiran

+0

Hoặc bạn có thể đề xuất cho tôi một gói khác với cùng chức năng và cài đặt pip không? – mertyildiran

+0

Khá nhiều gói cung cấp hỗ trợ âm thanh sẽ yêu cầu các thư viện bổ sung của bên thứ ba. Có một gói cho PyAudio vì đó là một gói Python. Thư viện 'portaudio' mà nó yêu cầu không phải là. – larsks

13

này làm việc cho tôi, tôi đã có cùng một vấn đề:

nếu bạn muốn cài đặt PyAudio bên trong một virtualenv, cài đặt các tiêu đề phát triển PortAudio từ APT, sau đó PyAudio:

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

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

+0

nó hoạt động hoàn hảo. – ShivaGuntuku

+0

nó hoạt động .... cảm ơn rất nhiều ... – vishwakarma09

+0

Tính năng này đã hoạt động, thậm chí không cần phải thực hiện thẻ --allow-unverified –

Các vấn đề liên quan