【问题标题】:Unable to install PyAudio on M1 Mac [PortAudio already installed]无法在 M1 Mac 上安装 PyAudio [PortAudio 已安装]
【发布时间】:2021-09-15 22:36:10
【问题描述】:

我访问过很多论坛,尝试了 brew、pip、port 等不同的方法,但仍然面临同样的错误。

View this Image for more detail

src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
    #include "portaudio.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command '/usr/bin/gcc' failed with exit code 1

谁能帮忙?

【问题讨论】:

    标签: pip homebrew pyaudio macos-big-sur portaudio


    【解决方案1】:

    此解决方案已在 M1 Macs 上测试[请与其他设备核实]。

    在您的系统上安装 HomeBrew 后,执行 PortAudio 的安装。接下来按照以下步骤操作:

    使用命令安装PortAudio

    sudo brew install portaudio

    PortAudio安装成功后,输入以下命令。

    sudo nano $HOME/.pydistutils.cfg

    接下来,在打开的窗口中输入以下几行

    [build_ext]
    include_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/include/
    include_dirs=/Users/<enter-your-system-username>/homebrew/Cellar/portaudio/19.20140130/lib/
    

    注意:PortAudio 的位置可能对您不同,也不要忘记替换您的 PC 用户名。

    最后运行命令

    pip 安装 pyaudio

    pip3 安装 pyaudio

    【讨论】:

    • 此解决方案对我有用,但起初我收到此错误:pydistutils.cfg' [line 3]: option 'include_dirs' in section 'build_ext' already exists。在第一个include_dirs 之后,我为第二个include_dirs 添加了一个新部分build_ext_1,它起作用了。
    【解决方案2】:

    对我来说是:

    brew install portaudio
    python -m pip install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio
    

    【讨论】:

    • 我刚刚做了brew install portaudio,一切都很好。
    猜你喜欢
    • 1970-01-01
    • 2021-06-29
    • 1970-01-01
    • 2020-12-18
    • 2021-09-20
    • 2021-11-15
    • 2021-05-16
    • 2022-01-09
    • 2021-10-28
    相关资源
    最近更新 更多