安装PyAudio时出现错误 "Failed Building Wheel for PyAudio"。

11

我一直在尝试安装PyAudio,但是一直没有成功。我已经尝试了几种不同的解决方案,并且使用homebrew安装了前置库"portaudio"。我也寻找了解决gcc错误的方法,但是这只导致另一个错误出现,显示“Error: command ‘clang’ failed with exit status 1”。我感觉现在我的问题在于对这些错误信息的含义缺乏理解,因为我在python方面缺乏经验。非常感谢任何帮助。谢谢。

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/
4个回答

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

如果再次失败,请在pip3之前执行以下操作

$ sudo apt install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg libav-tools

3

我尝试使用这个命令,它可以在Anaconda提示符中正常工作:

conda install PyAudio`

这在我的Windows 10上有效 > py -v 3.8.10 - Bharath Kumar

2

1

您也可以使用:

pip install pipwin
pipwin install pyaudio

这不使用Anaconda,只使用pip。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接