win32com module not found

懵懂的女人 提交于 2019-12-11 04:38:40

问题


I am trying to get pyttsx3 up and running on my computer. I did pip install pyttsx3 and pip install pypiwin32 I can see both of them in my python directory.

I type this code in to test it:

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

This is what comes out:

Traceback (most recent call last): File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3__init__.py", line 44, in init eng = _activeEngines[driverName] File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\weakref.py", line 131, in getitem o = self.datakey KeyError: None

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Danny\Desktop\python text to speech.py", line 9, in engine = pyttsx3.init() File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3__init__.py", line 46, in init eng = Engine(driverName, debug) File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\engine.py", line 52, in init self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\driver.py", line 77, in init self._driver = self._module.buildDriver(weakref.proxy(self)) File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 22, in buildDriver return SAPI5Driver(proxy) File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 41, in init self.setProperty('voice', self.getProperty('voice')) File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 83, in setProperty self._tts.Voice = token File "C:\Users\Danny\AppData\Local\Programs\Python\Python36\lib\site-packages\win32com\client\dynamic.py", line 549, in setattr self.oleobj.Invoke(entry.dispid, 0, invoke_type, 0, value) pywintypes.com_error: (-2147352573, 'Member not found.', None, None)

I tried the same thing on another computer that already had both installed, and got the same output. Any idea what is going on with the win32com? I have no experience with it and am pretty lost. Thanks.


回答1:


Ok, so I found the answer looking at other problems that were related to the win32com module. Basically what you need to do is navigate to your python scripts folder (in my case: C:\Users\Danny\AppData\Local\Programs\Python\Python36\Scripts) and run pywin32_postinstall. Upon running that script, it works perfectly!

Cheers!



来源:https://stackoverflow.com/questions/49563327/win32com-module-not-found

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