Shivani Parekh
Shivani Parekh

Reputation: 85

Error finding module named pywintypes (Text-to-Speech in python using pyttsx3 on windows 10)

I have tried every solution on Stackoverflow but my error doesn't seem to get solved . I have tried uninstalling and installing this package pyttsx3 also . Please help me . here is the error I am getting .

Traceback (most recent call last): File "C:\Python37\lib\site-packages\pyttsx3__init__.py", line 20, in init

eng = _activeEngines[driverName]

File "C:\Python37\lib\weakref.py", line 137, in getitem o = self.datakey KeyError: 'sapi5'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:/Python37/tts2.py", line 2, in

engine = pyttsx3.init("sapi5")

File "C:\Python37\lib\site-packages\pyttsx3__init__.py", line 22, in init

eng = Engine(driverName, debug)

File "C:\Python37\lib\site-packages\pyttsx3\engine.py", line 30, in init

self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)

File "C:\Python37\lib\site-packages\pyttsx3\driver.py", line 50, in init

self._module = importlib.import_module(name)

File "C:\Python37\lib\importlib__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level)

File "", line 1006, in _gcd_import

File "", line 983, in _find_and_load

File "", line 967, in _find_and_load_unlocked

File "", line 677, in _load_unlocked

File "", line 728, in exec_module

File "", line 219, in _call_with_frames_removed

File "C:\Python37\lib\site-packages\pyttsx3\drivers\sapi5.py", line 10, in

import pythoncom

File "C:\Python37\lib\site-packages\pythoncom.py", line 2, in

import pywintypes

ModuleNotFoundError: No module named 'pywintypes'

My Code Is :

import pyttsx3
engine = pyttsx3.init("sapi5")
engine.say('Welcome ')
engine.runAndWait()

Upvotes: 0

Views: 3383

Answers (2)

Harnoorbir Singh
Harnoorbir Singh

Reputation: 1

Try Installing pywin32 with this command:

pip install pywin32

If that does not work than follow steps given:

Step - 1- Install pywin32 with this command:

pip install pywin32

Step - 2 - Import win32api just like this:

from win32api import *

Upvotes: 0

Sorunlu
Sorunlu

Reputation: 13

I've had issue like this last week. Its turns out to be I've had multiple version of python installed. Please try

python3 -m pip install pywintypes

see if is going to cure your problem.

Upvotes: 0

Related Questions