【问题标题】:Error coming in this CreateObject from com types?来自 com 类型的 CreateObject 错误?
【发布时间】:2021-05-04 08:06:35
【问题描述】:

这是我的简单代码:

from comtypes.client import CreateObject
engine = CreateObject("SAPI.SpVoice")
#stream = CreateObject("SAPI.SpFileStream")

然后就出现了这么多错误。

回溯(最近一次通话最后一次): 文件“E:\Python\lib\ctypes_init_.py”,第 123 行,WINFUNCTYPE return win_functype_cache[(restype, argtypes, flags)] KeyError: (, (, ), 0) 在处理上述异常的过程中,又出现了一个异常: 回溯(最近一次通话最后): 文件“E:\Python\cv2_tutorials\Text to Speech\text2speech.py​​”,第 2 行,在 引擎 = CreateObject("SAPI.SpVoice") CreateObject 中的文件“E:\Python\lib\site-packages\comtypes\client_init.py”,第 250 行 返回管理(obj,clsid,接口=接口) manage 中的文件“E:\Python\lib\site-packages\comtypes\client_init.py”,第 188 行 obj = GetBestInterface(obj) GetBestInterface 中的文件“E:\Python\lib\site-packages\comtypes\client_init.py”,第 110 行 mod = GetModule(tlib) GetModule 中的文件“E:\Python\lib\site-packages\comtypes\client_generate.py”,第 118 行 mod = _CreateWrapper(tlib,路径名) _CreateWrapper mod = my_import(fullname) 中的文件“E:\Python\lib\site-packages\comtypes\client_generate.py”,第 198 行 my_import 中的文件“E:\Python\lib\site-packages\comtypes\client_generate.py”,第 19 行 return import(fullname, globals(), locals(), ['DUMMY']) 文件“E:\Python\lib\site-packages\comtypes\gen_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py”,第 438 行,在 ISpeechBaseStream.方法 = [ setattr 中的文件“E:\Python\lib\site-packages\comtypes_init.py”,第 323 行 self.make_methods(value) make_methods 中的文件“E:\Python\lib\site-packages\comtypes_init.py”,第 692 行 原型 = WINFUNCTYPE(restype, *argtypes) 文件“E:\Python\lib\ctypes_init.py”,第 125 行,WINFUNCTYPE 类 WinFunctionType(_CFuncPtr): TypeError: argtypes 中的项目 1 按值传递联合,这是不受支持的。

我知道一件事是非常简单的错误,但我找不到。

【问题讨论】:

    标签: python comtypes pyttsx3


    【解决方案1】:

    好吧,我得到了我自己问题的答案 答案很简单:- **只需卸载 pyttsx3 和 comtypes :**

    pip uninstall pyttsx3
    pip uninstall comtypes
    

    **然后通过键入以下内容重新安装它们:**

    pip install comtypes
    pip install -Iv pyttsx3==2.6 -U
    

    这会解决问题,稍后谢谢我

    【讨论】:

      猜你喜欢
      • 2016-06-28
      • 2018-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-14
      相关资源
      最近更新 更多