pyaudio 没有安装
pyaudio is not installing
嘿,我正在做一个 JARVIS 项目,当我 运行 我的代码时,它给了我一个错误,没有名为 pyaudio 的模块。
当我尝试通过键入 pip install pyaudio 来安装它时,它给了我错误。
我在 windows 机器上(windows 7)
Complete output (9 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
copying src\pyaudio.py -> build\lib.win32-3.7
running build_ext
building '_portaudio' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for V
isual Studio": https://visualstudio.microsoft.com/downloads/
这是我的 FARADAY AI 的代码。我在 python 3.8(32 位机器)上 python 也是 32 位的。
import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak('Good Morning Sir')
elif hour>=12 and hour<18:
speak('Good Afternoon sir')
else:
speak('Good Evening sir')
speak('I am Jarvis')
def takeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print('Listening...')
r.pause_threshold = 1
audio = r.listen(source)
try:
print('Recognizing...')
query = r.recognize_google(audio, language='en')
print(f"User said: {query}\n")
except Exception as e:
print('say that again pls sir')
return "None"
return query
if __name__ == "__main__":
wishMe()
while True:
query = takeCommand().lower()
if 'wikipedia' in query:
speak('Searching wikipedia')
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=2)
speak("According to Wikipedia")
print(results)
speak(results)
elif 'open Youtube in query':
webbrowser.open('youtube.com')
elif 'how handsome am i in query':
speak('you are very Handsome sir')
elif 'open Google in query':
googlePath = ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
os.startfile(googlePath)
这是一个很常见的问题,我记得这是我在 python 上的第一个错误。你得到一个错误 can't install pyaudio 因为你的系统没有构建 pyaudio 的成分。您应该转到 https://www.lfd.uci.edu/~gohlke/pythonlibs/ 并按 Ctrl + F 并键入 pyaudio 并下载与您的机器和 python 版本相匹配的 whl 文件。下载后,您应该在安装它的目录中按住 Shift 键并右键单击,然后在此处单击打开电源 shell window。最后键入 pip install 和 whl 文件名的首字母,然后按 TAB 键,最后按 ENTER 键。轰!你已经安装了pyaudio。
不幸的是,我只在 Chrombook 上遇到了完全相同的问题,但没有解决。如果它在 Windows 系统上,您可以很容易地解决问题:
- pip 安装 pipwin
- pipwin 安装 pyaudio
嘿,我正在做一个 JARVIS 项目,当我 运行 我的代码时,它给了我一个错误,没有名为 pyaudio 的模块。 当我尝试通过键入 pip install pyaudio 来安装它时,它给了我错误。 我在 windows 机器上(windows 7)
Complete output (9 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
copying src\pyaudio.py -> build\lib.win32-3.7
running build_ext
building '_portaudio' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for V
isual Studio": https://visualstudio.microsoft.com/downloads/
这是我的 FARADAY AI 的代码。我在 python 3.8(32 位机器)上 python 也是 32 位的。
import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak('Good Morning Sir')
elif hour>=12 and hour<18:
speak('Good Afternoon sir')
else:
speak('Good Evening sir')
speak('I am Jarvis')
def takeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print('Listening...')
r.pause_threshold = 1
audio = r.listen(source)
try:
print('Recognizing...')
query = r.recognize_google(audio, language='en')
print(f"User said: {query}\n")
except Exception as e:
print('say that again pls sir')
return "None"
return query
if __name__ == "__main__":
wishMe()
while True:
query = takeCommand().lower()
if 'wikipedia' in query:
speak('Searching wikipedia')
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=2)
speak("According to Wikipedia")
print(results)
speak(results)
elif 'open Youtube in query':
webbrowser.open('youtube.com')
elif 'how handsome am i in query':
speak('you are very Handsome sir')
elif 'open Google in query':
googlePath = ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe")
os.startfile(googlePath)
这是一个很常见的问题,我记得这是我在 python 上的第一个错误。你得到一个错误 can't install pyaudio 因为你的系统没有构建 pyaudio 的成分。您应该转到 https://www.lfd.uci.edu/~gohlke/pythonlibs/ 并按 Ctrl + F 并键入 pyaudio 并下载与您的机器和 python 版本相匹配的 whl 文件。下载后,您应该在安装它的目录中按住 Shift 键并右键单击,然后在此处单击打开电源 shell window。最后键入 pip install 和 whl 文件名的首字母,然后按 TAB 键,最后按 ENTER 键。轰!你已经安装了pyaudio。
不幸的是,我只在 Chrombook 上遇到了完全相同的问题,但没有解决。如果它在 Windows 系统上,您可以很容易地解决问题:
- pip 安装 pipwin
- pipwin 安装 pyaudio