LoginSignup
4
2

More than 5 years have passed since last update.

WindowsにPyAudioをインストールする際にはバージョンに注意

Posted at

昨日Windows Server 2016にPythonとPyAudioをインストールしようとしてインストールできずハマりました。
当初はビルド済みのアーカイブを入れてみようとか、PortAudio入れてみようとか考えましたが単純なことだったのでメモがてら残しておきます。

以下のURLを見てください。
https://pypi.org/project/PyAudio/#files

この記事を書いている時点でに対応しているPythonの最新バージョンはcp36です。
しかし昨日、最初にインストールしたPythonは3.7でした。
これが問題でPython3.7が入った状態でpip install pyaudioをするとダウンロードはするもののその後以下のようなエラーが出ます。

Collecting pyaudio
  Downloading https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
~~~中略~~~
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    copying src\pyaudio.py -> build\lib.win32-3.7
    running build_ext
    building '_portaudio' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

ちなみに http://landinghub.visualstudio.com/visual-cpp-build-tools は404です。リダイレクトして欲しいものですね。

Microsoft Visual C++ Build Toolsで検索すると、Cコンパイラのインストールが見つかり、記載の通りツールをインストールすると今度は以下のエラーになります。

Collecting pyaudio
  Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
~~~中略~~~
    src/_portaudiomodule.c(29): fatal error C1083: include ファイルを開けません。'portaudio.h':No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

なんとかできそうな気もしますが面倒なのでよほど新しいバージョンを使いたいとかでなければPyAudio側に合わせたほうが良いかなと思います。

4
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2