问题
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