Python ModuleNotFoundError despite the modules being installed

爷,独闯天下 提交于 2021-01-29 07:47:26

问题


While importing:

import speech_recognition as sr
import pyttsx3

I get the error:

ModuleNotFoundError: No module named 'speech_recognition'
ModuleNotFoundError: No module named 'pyttsx3'

回答1:


Pls.run pip list in the same virtual env and check if your modules are present in the list.

Also, pls.run in the python terminal the same import first.




回答2:


I assume you are using Python 3 and your pip is installed and functional (you might need to use sudo or run command as admin, depending on your OS):

sudo pip uninstall speechrecognition
sudo pip install speechrecognition --no-cache-dir

And then:

sudo pip uninstall pyttsx3 
sudo pip install pyttsx3 --no-cache-dir

No cache dir option will make sure that you download dependencies from scratch in case your previous download in cache had any problems. It could also be that your are using a VENV or your Environment variables are messed up. Make sure which Python and Pip are you using:

python --version
pip -V


来源:https://stackoverflow.com/questions/64301324/python-modulenotfounderror-despite-the-modules-being-installed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!