ModuleNotFoundError:Mac上没有名为“pyaudio”的模块(已安装Anaconda)

2024-09-28 20:51:08 发布

您现在位置:Python中文网/ 问答频道 /正文

this教程之后,我正在尝试使用python制作语音助手。 我在我的Mac电脑上安装了Anaconda(个人版),就像那个家伙建议的那样。我在Pycharm终端中说了“conda安装PyAudio”,它成功安装(我猜):

(venv) (base) Adityas-MacBook-Air:VoiceRec adityabakshi$ conda install pyaudio Collecting package metadata (current_repodata.json): done Solving environment: done

Package Plan

environment location: /Users/adityabakshi/opt/anaconda3

added / updated specs: - pyaudio

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
portaudio-19.6.0           |       h647c56a_4          75 KB
pyaudio-0.2.11             |   py38h1de35cc_2         203 KB
------------------------------------------------------------
                                       Total:         277 KB

The following NEW packages will be INSTALLED:

portaudio pkgs/main/osx-64::portaudio-19.6.0-h647c56a_4
pyaudio pkgs/main/osx-64::pyaudio-0.2.11-py38h1de35cc_2

Proceed ([y]/n)? y

Downloading and Extracting Packages portaudio-19.6.0 | 75 KB | ################################################################################## | 100% pyaudio-0.2.11 | 203 KB | ################################################################################## | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done

但是,当我运行代码时:

import pyttsx3 as p
import speech_recognition as sr

engine = p.init()

engine.say("Hello, I'm your voice assistant")
engine.runAndWait()

r = sr.Recognizer()

with sr.Microphone() as source:
    r.energy_threshold = 10000
    r.adjust_for_ambient_noise(source, 1.2)
    print("listening..")
    audio = r.listen(source)
    text = r.recognize_google(audio)
    print(text)

我得到了这个错误:

/Users/adityabakshi/PycharmProjects/VoiceRec/venv/bin/python /Users/adityabakshi/PycharmProjects/VoiceRec/voiceapp.py Traceback (most recent call last): File "/Users/adityabakshi/PycharmProjects/VoiceRec/venv/lib/python3.8/site-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 "/Users/adityabakshi/PycharmProjects/VoiceRec/voiceapp.py", line 11, in with sr.Microphone() as source: File "/Users/adityabakshi/PycharmProjects/VoiceRec/venv/lib/python3.8/site-packages/speech_recognition/init.py", line 79, in init self.pyaudio_module = self.get_pyaudio() File "/Users/adityabakshi/PycharmProjects/VoiceRec/venv/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

Process finished with exit code 1

我不明白…我已经安装了anaconda和pyaudio,但是这个错误是如何显示的?(我是Python的初学者)。有人能帮我修一下吗?谢谢


Tags: pykbvenvinitpackagesasspeechusers