报错截图如下:
解决方案:
Python38_32\Lib\site-packages\comtypes\__init__.py的CoCreateInstance()里添加CoInitialize()
下面代码中的倒数第3行
def CoCreateInstance(clsid, interface=None, clsctx=None, punkouter=None):
"""The basic windows api to create a COM class object and return a
pointer to an interface.
"""
if clsctx is None:
clsctx = CLSCTX_SERVER
if interface is None:
interface = IUnknown
p = POINTER(interface)()
iid = interface._iid_
CoInitialize()
_ole32.CoCreateInstance(byref(clsid), punkouter, clsctx, byref(iid), byref(p))
return p
参考: https://blog.csdn.net/wjx199112/article/details/121649643