Back to PyAudio

PyAudio Compilation Hints

Here are some hints for compiling PortAudio and PyAudio on various platforms:

Generally speaking, you must first install the PortAudio v19 library before building PyAudio.

General UNIX Guide

  1. Get the latest PortAudio v19 from subversion, then build and install:
    % ./configure
    % make
    % make install # you may need to be root
    (Or better yet, use your package manager to install PortAudio v19)
  2. Extract PyAudio; to build and install, run:
    % python setup.py install

Microsoft Windows

If you are targeting native Win32 Python, you will need either MinGW (via Cygwin) or Microsoft Visual Studio. Below are compilation hints for using MinGW under the Cygwin build environment. To build PyAudio using Microsoft Visual Studio, check out Sebastian Audet's instructions.

Note: I've only tested this under Cygwin's build environment. Your mileage may vary in other environments (i.e., compiling PortAudio with MinGW's compiler and environment).

  1. Download and untar PyAudio.
  2. Download the PortAudio library and untar it to portaudio-v19/ inside the PyAudio directory.
    (For example, if your PyAudio directory is ~/PyAudio-0.2.4/, then the PortAudio source should be in ~/PyAudio-0.2.4/portaudio-v19/)
  3. Build PortAudio. When running configure, be sure to use -mno-cygwin (under cygwin) to generate native Win32 binaries:
    % cd portaudio-v19
    % CFLAGS="-mno-cygwin" LDFLAGS="-mno-cygwin" ./configure
    % make
  4. To build PyAudio, from inside the pyaudio-0.2.4/ directory, run:
    % python setup.py build --static-link -cmingw32
    Be sure to invoke the native Win32 python (rather than cygwin's python). The --static-link option statically links in the PortAudio library to the PyAudio module, which is probably the most hassle-free way to go on Windows.

    Update: You may run into trouble compiling when using a recent version of Cygwin. From boodebr.org:

    Update: 2008-09-10
    
    Recent versions of Cygwin binutils have version numbers that are
    breaking the version number parsing, resulting in errors like:
    ValueError: invalid version number '2.18.50.20080625'
    
    To fix this, edit distutils/version.py. At line 100, replace:
    
      version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$',
                              re.VERBOSE)
    
    with
    
      version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? (\. (\d+))?$',
                              re.VERBOSE)
    
  5. To install PyAudio:
    % python setup.py install --skip-build
    The --skip-build option prevents Python from searching your system for Visual Studio and the .NET framework.
Back to PyAudio