You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac M1已安装PyAudio但Speech_recognition模块提示找不到组件

问题描述

我已尝试Stack Overflow上几乎所有解决方案,但仍无法运行以下代码:

import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
     print("Listening...")
     r.pause_threshold = 1
     audio = r.listen(source)

主要报错信息

Could not import the PyAudio C module 'pyaudio._portaudio'.
Traceback (most recent call last):
  File "/Users/sadra/opt/anaconda3/lib/python3.8/site-packages/speech_recognition/__init__.py", line 108, in get_pyaudio
    import pyaudio
  File "/Users/sadra/opt/anaconda3/lib/python3.8/site-packages/pyaudio/__init__.py", line 111, in <module>
    import pyaudio._portaudio as pa
ImportError: dlopen(/Users/sadra/opt/anaconda3/lib/python3.8/site-packages/pyaudio/_portaudio.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '_PaMacCore_SetupChannelMap'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sadra/Desktop/Project/irandoc/mirror/sr.py", line 3, in <module>
    with sr.Microphone() as source:
  File "/Users/sadra/opt/anaconda3/lib/python3.8/site-packages/speech_recognition/__init__.py", line 80, in __init__
    self.pyaudio_module = self.get_pyaudio()
  File "/Users/sadra/opt/anaconda3/lib/python3.8/site-packages/speech_recognition/__init__.py", line 110, in get_pyaudio
    raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation

单独导入PyAudio的报错

单独执行import pyaudio时也会报错:

Could not import the PyAudio C module 'pyaudio._portaudio'.
Traceback (most recent call last):
  File "/Users/sadra/Desktop/Project/irandoc/mirror/sr.py", line 1, in <module>
    import pyaudio
  File "/Users/sadra/opt/anaconda3/lib/python3.8/site-packages/pyaudio/__init__.py", line 111, in <module>
    import pyaudio._portaudio as pa
ImportError: dlopen(/Users/sadra/opt/anaconda3/lib/python3.8/site-packages/pyaudio/_portaudio.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '_PaMacCore_SetupChannelMap'

我尝试了多种方式安装PortAudio和PyAudio,但问题仍未解决。


内容的提问来源于stack exchange,提问作者Sadra Ne

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 05:58:27