[英]How to resolve the Python error “ModuleNotFoundError: No module named 'pyaudio'”?
File "/usr/local/lib/python3.7/dist-packages/speech_recognition/__init__.py", line 108, in get_pyaudio
import pyaudio
ModuleNotFoundError: No module named 'pyaudio'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "speechrecog.py", line 5, in <module>
with sr.Microphone() as source:
File "/usr/local/lib/python3.7/dist-packages/speech_recognition/__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "/usr/local/lib/python3.7/dist-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
Try installing pyaudio (details here https://people.csail.mit.edu/hubert/pyaudio/ ).尝试安装 pyaudio(详细信息在这里https://people.csail.mit.edu/hubert/pyaudio/ )。 Good luck祝你好运
This usually happens when your program is trying to use a module that you yourself haven't installed.这通常发生在您的程序尝试使用您自己尚未安装的模块时。 Some modules are built into Python itself like math.一些模块像数学一样内置在 Python 本身中。 The way you need to use pyaudio is to install it into the directory you are already in for this project.您需要使用 pyaudio 的方式是将其安装到您已经在此项目中的目录中。
in a terminal window, cd
to your project directory, run python -m pip install pyaudio
在终端 window 中, cd
到您的项目目录,运行python -m pip install pyaudio
Let me know if that works.让我知道这是否有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.