Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errors installing PyAudio "Failed Building Wheel for PyAudio"

I have been having trouble finding a fix for getting PyAudio installed on my machine. I have tried a few different solutions and i do have the prerequisite library "portaudio" installed using homebrew. I have also looked for solutions to the gcc error that appears at the bottom of the output and to which solutions only generated a different error that read "Error: command ‘clang’ failed with exit status 1". I feel at this point it is some lack of understanding of the implications of these error messages due to a lack of experience in python that keeps me from understanding a resolution. Any help is greatly appreciated. Thank you.

MacBook-Pro-2:~ MyName$ pip install pyaudio
Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz
Building wheels for collected packages: pyaudio
  Running setup.py bdist_wheel for pyaudio ... error
  Complete output from command /Users/MyName/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/l8/g1463xmj059g0qmss57qr3bh0000gp/T/pip-build-r_jfrp4_/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/l8/g1463xmj059g0qmss57qr3bh0000gp/T/tmpxdj3hlo2pip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.7-x86_64-3.6
  copying src/pyaudio.py -> build/lib.macosx-10.7-x86_64-3.6
  running build_ext
  building '_portaudio' extension
  creating build/temp.macosx-10.7-x86_64-3.6
  creating build/temp.macosx-10.7-x86_64-3.6/src
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/MyName/anaconda3/include -arch x86_64 -I/Users/MyName/anaconda3/include -arch x86_64 -DMACOSX=1 -I/Users/MyName/anaconda3/include/python3.6m -c src/_portaudiomodule.c -o build/temp.macosx-10.7-x86_64-3.6/src/_portaudiomodule.o
  In file included from src/_portaudiomodule.c:33:
  In file included from /usr/local/include/pa_mac_core.h:48:
  In file included from /System/Library/Frameworks/AudioUnit.framework/Headers/AudioUnit.h:1:
  In file included from /System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnit.h:16:
  In file included from /System/Library/Frameworks/AudioToolbox.framework/Headers/AudioComponent.h:167:
  In file included from /System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudioTypes.h:30:
  In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:72:
  /usr/local/include/Block.h:16:3: error: Never include this file directly. Use <lzma.h> instead.
  #       error Never include this file directly. Use <lzma.h> instead.
          ^
  /usr/local/include/Block.h:93:2: error: unknown type name 'lzma_check'
          lzma_check check;
          ^
  /usr/local/include/Block.h:148:2: error: unknown type name 'lzma_vli'
          lzma_vli compressed_size;
          ^
  /usr/local/include/Block.h:172:2: error: unknown type name 'lzma_vli'
          lzma_vli uncompressed_size;
          ^
  /usr/local/include/Block.h:200:2: error: unknown type name 'lzma_filter'
          lzma_filter *filters;
          ^
  /usr/local/include/Block.h:217:20: error: use of undeclared identifier 'LZMA_CHECK_SIZE_MAX'
          uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
                            ^
  /usr/local/include/Block.h:231:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int3;
          ^
  /usr/local/include/Block.h:232:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int4;
          ^
  /usr/local/include/Block.h:233:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int5;
          ^
  /usr/local/include/Block.h:234:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int6;
          ^
  /usr/local/include/Block.h:235:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int7;
          ^
  /usr/local/include/Block.h:236:2: error: unknown type name 'lzma_vli'
          lzma_vli reserved_int8;
          ^
  /usr/local/include/Block.h:237:2: error: unknown type name 'lzma_reserved_enum'
          lzma_reserved_enum reserved_enum1;
          ^
  /usr/local/include/Block.h:238:2: error: unknown type name 'lzma_reserved_enum'
          lzma_reserved_enum reserved_enum2;
          ^
  /usr/local/include/Block.h:239:2: error: unknown type name 'lzma_reserved_enum'
          lzma_reserved_enum reserved_enum3;
          ^
  /usr/local/include/Block.h:240:2: error: unknown type name 'lzma_reserved_enum'
          lzma_reserved_enum reserved_enum4;
          ^
  /usr/local/include/Block.h:261:2: error: unknown type name 'lzma_bool'
          lzma_bool ignore_check;
          ^
  /usr/local/include/Block.h:263:2: error: unknown type name 'lzma_bool'
          lzma_bool reserved_bool2;
          ^
  /usr/local/include/Block.h:264:2: error: unknown type name 'lzma_bool'
          lzma_bool reserved_bool3;
          ^
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  error: command '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 /Users/MyName/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/l8/g1463xmj059g0qmss57qr3bh0000gp/T/pip-build-r_jfrp4_/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 /var/folders/l8/g1463xmj059g0qmss57qr3bh0000gp/T/pip-mxjvhl6h-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.7-x86_64-3.6
    copying src/pyaudio.py -> build/lib.macosx-10.7-x86_64-3.6
    running build_ext
    building '_portaudio' extension
    creating build/temp.macosx-10.7-x86_64-3.6
    creating build/temp.macosx-10.7-x86_64-3.6/src
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/MyName/anaconda3/include -arch x86_64 -I/Users/MyName/anaconda3/include -arch x86_64 -DMACOSX=1 -I/Users/MyName/anaconda3/include/python3.6m -c src/_portaudiomodule.c -o build/temp.macosx-10.7-x86_64-3.6/src/_portaudiomodule.o
    In file included from src/_portaudiomodule.c:33:
    In file included from /usr/local/include/pa_mac_core.h:48:
    In file included from /System/Library/Frameworks/AudioUnit.framework/Headers/AudioUnit.h:1:
    In file included from /System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnit.h:16:
    In file included from /System/Library/Frameworks/AudioToolbox.framework/Headers/AudioComponent.h:167:
    In file included from /System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudioTypes.h:30:
    In file included from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:72:
    /usr/local/include/Block.h:16:3: error: Never include this file directly. Use <lzma.h> instead.
    #       error Never include this file directly. Use <lzma.h> instead.
            ^
    /usr/local/include/Block.h:93:2: error: unknown type name 'lzma_check'
            lzma_check check;
            ^
    /usr/local/include/Block.h:148:2: error: unknown type name 'lzma_vli'
            lzma_vli compressed_size;
            ^
    /usr/local/include/Block.h:172:2: error: unknown type name 'lzma_vli'
            lzma_vli uncompressed_size;
            ^
    /usr/local/include/Block.h:200:2: error: unknown type name 'lzma_filter'
            lzma_filter *filters;
            ^
    /usr/local/include/Block.h:217:20: error: use of undeclared identifier 'LZMA_CHECK_SIZE_MAX'
            uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
                              ^
    /usr/local/include/Block.h:231:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int3;
            ^
    /usr/local/include/Block.h:232:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int4;
            ^
    /usr/local/include/Block.h:233:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int5;
            ^
    /usr/local/include/Block.h:234:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int6;
            ^
    /usr/local/include/Block.h:235:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int7;
            ^
    /usr/local/include/Block.h:236:2: error: unknown type name 'lzma_vli'
            lzma_vli reserved_int8;
            ^
    /usr/local/include/Block.h:237:2: error: unknown type name 'lzma_reserved_enum'
            lzma_reserved_enum reserved_enum1;
            ^
    /usr/local/include/Block.h:238:2: error: unknown type name 'lzma_reserved_enum'
            lzma_reserved_enum reserved_enum2;
            ^
    /usr/local/include/Block.h:239:2: error: unknown type name 'lzma_reserved_enum'
            lzma_reserved_enum reserved_enum3;
            ^
    /usr/local/include/Block.h:240:2: error: unknown type name 'lzma_reserved_enum'
            lzma_reserved_enum reserved_enum4;
            ^
    /usr/local/include/Block.h:261:2: error: unknown type name 'lzma_bool'
            lzma_bool ignore_check;
            ^
    /usr/local/include/Block.h:263:2: error: unknown type name 'lzma_bool'
            lzma_bool reserved_bool2;
            ^
    /usr/local/include/Block.h:264:2: error: unknown type name 'lzma_bool'
            lzma_bool reserved_bool3;
            ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/Users/MyName/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/l8/g1463xmj059g0qmss57qr3bh0000gp/T/pip-build-r_jfrp4_/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 /var/folders/l8/g1463xmj059g0qmss57qr3bh0000gp/T/pip-mxjvhl6h-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/l8/g1463xmj059g0qmss57qr3bh0000gp/T/pip-build-r_jfrp4_/pyaudio/
like image 868
G-Slice Avatar asked Mar 11 '18 19:03

G-Slice


4 Answers

$ sudo apt-get install portaudio19-dev python-all-dev
$ pip3 install pyaudio

That is all, if failed again, do this before pip3 $ sudo apt install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg libav-tools

like image 165
Kearney Avatar answered Oct 21 '22 13:10

Kearney


I know this question is old but

If you're on MacOs

brew update
brew install portaudio
brew link --overwrite portaudio

Source: https://medium.com/@moon_is_beautiful/when-cant-install-pyaudio-with-pip-190973840dbf

like image 39
Luis Liz Avatar answered Oct 21 '22 12:10

Luis Liz


I tried to use this command and it works from the Anaconda prompt:

conda install PyAudio`
like image 2
Saïda Meftah Avatar answered Oct 21 '22 13:10

Saïda Meftah


You can also use:

pip install pipwin
pipwin install pyaudio

This doesn't use anaconda, just pip.

like image 1
Rik Mulder Avatar answered Oct 21 '22 13:10

Rik Mulder