pyttsx3 icon indicating copy to clipboard operation
pyttsx3 copied to clipboard

ModuleNotFoundError: No module named 'pywintypes'

Open Flynni123 opened this issue 4 years ago • 4 comments

Got the Error above while running:

import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()

Full Output:

Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\Python\Python38\site-packages\pyttsx3\__init__.py", line 20, in init
    eng = _activeEngines[driverName]
  File "C:\Program Files\Python38\lib\weakref.py", line 131, in __getitem__
    o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "C:\Users\...\AppData\Roaming\Python\Python38\site-packages\pyttsx3\__init__.py", line 22, in init
    eng = Engine(driverName, debug)
  File "C:\Users\...\AppData\Roaming\Python\Python38\site-packages\pyttsx3\engine.py", line 30, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  File "C:\Users\...\AppData\Roaming\Python\Python38\site-packages\pyttsx3\driver.py", line 50, in __init__
    self._module = importlib.import_module(name)
  File "C:\Program Files\Python38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\...\AppData\Roaming\Python\Python38\site-packages\pyttsx3\drivers\sapi5.py", line 10, in <module>
    import pythoncom
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\...\AppData\Roaming\Python\Python38\site-packages\pythoncom.py", line 2, in <module>
    import pywintypes
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'pywintypes'

Any help?

Flynni123 avatar Mar 03 '21 20:03 Flynni123

Install the pypiwin32 module.

TotallyAProgrammer avatar Mar 03 '21 21:03 TotallyAProgrammer

Having the pypiwin32 module, does not help fix this issue.

RedstonedLife avatar Mar 06 '21 13:03 RedstonedLife

@Flynni123 @RedstonedLife

import win32api

please import win32api with pyttsx3. I faced the same problem for a long time but recently came to know that pypiwin32 is imported in program by name win32api (and not as pypiwin32 or pywintypes). Please do tell whether this solution works for you.

Screenshot of my pyttsx3 program definition

Sam-Varghese avatar Apr 10 '21 01:04 Sam-Varghese

@Flynni123 @RedstonedLife

import win32api

please import win32api with pyttsx3. I faced the same problem for a long time but recently came to know that pypiwin32 is imported in program by name win32api (and not as pypiwin32 or pywintypes). Please do tell whether this solution works for you.

Screenshot of my pyttsx3 program definition

not work 👎

gamerfan82 avatar Dec 25 '21 09:12 gamerfan82