简体   繁体   English

无法解析导入“speech_recognition”

[英]Import "speech_recognition" could not be resolved

I installed the speech recognition and the pyttsx3 libraries我安装了语音识别和 pyttsx3 库

pip install SpeechRecognition
pip install pyttsx3

but when i try to import them it gives two errors但是当我尝试导入它们时它给出了两个错误

Import "speech_recognition" could not be resolved
Import "pyttsx3" could not be resolved

heres my code这是我的代码

import speech_recognition as sr
import pyttsx3

audio = sr.Recognizer()

Usually this happens because of virtual env or interpreter issues.通常发生这种情况是因为虚拟环境或解释器问题。 Possible fixes:可能的修复:

  1. Make sure that the interpreter you are using inside your IDE, is the same as the one in which you installed the libraries.确保您在 IDE 中使用的解释器与安装库的解释器相同。

  2. Same as above in case of virtual env.在虚拟环境的情况下与上面相同。

  3. If your IDE is VS Code, then open the settings.json file and set python server to Jedi instead of Microsoft/Pylance.如果你的 IDE 是 VS Code,那么打开 settings.json 文件,将 python 服务器设置为 Jedi 而不是 Microsoft/Pylance。

I faced similar issues, was unable to diagnose the exact cause, but somehow the popular CodeRunner extension and VS code's recommended python extensions were in conflict.我遇到了类似的问题,无法诊断出确切原因,但不知何故,流行的 CodeRunner 扩展和 VS 代码推荐的 python 扩展存在冲突。 Therefore, i disabled the former and the program executed without any issues因此,我禁用了前者并且程序执行没有任何问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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