Python voice assistant "ModuleNotFoundError: No module named 'gtts"


Question: Python voice assistant "ModuleNotFoundError: No module named 'gtts"

I'm trying make a voice assistant with python in VScode but i have a trouble. I installed all module already, one of module is not working. The gTTs(Google Text-to-Speech) is makes a error which is "ModuleNotFoundError: No module named 'gtts'"

I installed gTTs with pip installer in terminal again and python error again a lot but it did not happen anything. Just it shows to me "Requirement already satisfied"

import speech_recognition as sr from gtts import gTTS import os import time import playsound  def speak(text):     tts = gTTS(text=text, lang='en')     filename = 'jarvis_email_alert.mp3'     playsound.playsound(filename)      speak("hello tim") 

gTTS error in code line

PS C:\Users\huzey\OneDrive\Masaüstü\Python> &  C:/Users/huzey/AppData/Local/Microsoft/WindowsApps/python3.8.exe  c:/Users/huzey/OneDrive/Masaüstü/Python/ Traceback (most recent call last):   File "c:/Users/huzey/OneDrive/Masaüstü/Python/", line 2, in <module>     from gtts import gTTS ModuleNotFoundError: No module named 'gtts' PS C:\Users\huzey\OneDrive\Masaüstü\Python>  

How can i get the solution.

Total Answers: 3


Answers 1: of Python voice assistant "ModuleNotFoundError: No module named 'gtts"

If you didn't, try to restart Vscode after a pip install


Answers 2: of Python voice assistant "ModuleNotFoundError: No module named 'gtts"

it might be that your pip is using a different python version than your script

you can use python -m pip install gtts to install gtts to your python environment


Answers 3: of Python voice assistant "ModuleNotFoundError: No module named 'gtts"

I fixed that problem. İt seemed my system have two different python version. After realizing that I remove all pythons in system and install only one version of python. Before doing this when I open CMD and checking python version I seemed python 3.10 but the same time when I open VS code and checking python version it was showing me version of python 3.8. Now system have version of python 3.8.10 and working python error clearly! (after fixing a few line errors :))

Thank you for your ideas.