やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

pyaudioをインストールする

リアルタイムに音を鳴らすライブラリ。

参考

python - Cannot install pyaudio, gcc error - Stack Overflow

1回目

$ pip install pyaudio
Collecting pyaudio
  Downloading PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
  Running setup.py install for pyaudio ... error
    Complete output from command /.../game/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8931vzxp/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-l_qnnv13-record/install-record.txt --single-version-externally-managed --compile --install-headers /.../game/include/site/python3.6/pyaudio:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-i686-3.6
    copying src/pyaudio.py -> build/lib.linux-i686-3.6
    running build_ext
    building '_portaudio' extension
    creating build/temp.linux-i686-3.6
    creating build/temp.linux-i686-3.6/src
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/.../game/include -I/home/mint/.pyenv/versions/3.6.1/include/python3.6m -c src/_portaudiomodule.c -o build/temp.linux-i686-3.6/src/_portaudiomodule.o
    src/_portaudiomodule.c:29:23: fatal error: portaudio.h: そのようなファイルやディレクトリはありません
     #include "portaudio.h"
                           ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/.../game/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8931vzxp/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-l_qnnv13-record/install-record.txt --single-version-externally-managed --compile --install-headers /.../game/include/site/python3.6/pyaudio" failed with error code 1 in /tmp/pip-build-8931vzxp/pyaudio/

ググったら以下がヒット。依存ライブラリがあるらしい。

python - Cannot install pyaudio, gcc error - Stack Overflow

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

依存ライブラリのインストー

LinuxMint17.3ではSynapticを使ってインストールする。

libasound-dev

f:id:ytyaru:20170729154130p:plainf:id:ytyaru:20170729154136p:plainf:id:ytyaru:20170729154140p:plain

portaudio19-dev, libportaudiocpp

f:id:ytyaru:20170729154351p:plainf:id:ytyaru:20170729154407p:plainf:id:ytyaru:20170729154415p:plain

libjack-jackd2-0 が削除されます
libjack-dev (バージョン 1:0.121.3+20120418git75e3e20b-2.1ubuntu1) がインストールされます
libjack0 (バージョン 1:0.121.3+20120418git75e3e20b-2.1ubuntu1) がインストールされます
libportaudiocpp0 (バージョン 19+svn20140130-1) がインストールされます
portaudio19-dev (バージョン 19+svn20140130-1) がインストールされます

libportaudio2

インストール済みだった。

2回目

$ pip install pyaudio
Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
  Running setup.py install for pyaudio ... done
Successfully installed pyaudio-0.2.11

インストールできたっぽい。PyAudio (0.2.11)

$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
cycler (0.10.0)
matplotlib (2.0.2)
numpy (1.13.1)
olefile (0.44)
pgu (0.18)
Pillow (4.2.1)
pip (9.0.1)
PyAudio (0.2.11)
pygame (1.9.3)
PyOpenGL (3.1.0)
PyOpenGL-accelerate (3.1.0)
PyOpenGL-Demo (3.0.0)
pyparsing (2.2.0)
python-dateutil (2.6.1)
pytz (2017.2)
setuptools (28.8.0)
six (1.10.0)

所感

依存関係を手動解決するのが面倒。