简体   繁体   中英

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/ ). 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. The way you need to use pyaudio is to install it into the directory you are already in for this project.

in a terminal window, cd to your project directory, run python -m pip install pyaudio

Let me know if that works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM