ljc545w / ComWeChatRobot

PC微信机器人,实现获取通讯录,发送文本、图片、文件等消息,封装COM接口供Python、C#调用
1.65k stars 453 forks source link

module 'comtypes.gen.WeChatRobotCOMLib' has no attribute 'IRobotEvent' #102

Closed CharlesLi114 closed 2 years ago

CharlesLi114 commented 2 years ago

在注册之后运行 com 中的demo,提示错误: Traceback (most recent call last): File "D:/projects/P/AlphaCapture/other_apis/ComWeChatRobot-master-0830/ComWeChatRobot-master/Python/com/test.py", line 88, in wx = WeChatRobot(pid_list[0]) File "D:\projects\P\AlphaCapture\other_apis\ComWeChatRobot-master-0830\ComWeChatRobot-master\Python\com\wxRobot.py", line 145, in init self.robot = robot or _WeChatRobotClient.instance().robot File "D:\projects\P\AlphaCapture\other_apis\ComWeChatRobot-master-0830\ComWeChatRobot-master\Python\com\wxRobot.py", line 28, in instance cls._instance = cls() File "D:\projects\P\AlphaCapture\other_apis\ComWeChatRobot-master-0830\ComWeChatRobot-master\Python\com\wxRobot.py", line 33, in init self.event = comtypes.client.CreateObject("WeChatRobot.RobotEvent") File "D:\projects\P\AlphaCapture\wechatcapture\service\venv\lib\site-packages\comtypes\client__init.py", line 250, in CreateObject return _manage(obj, clsid, interface=interface) File "D:\projects\P\AlphaCapture\wechatcapture\service\venv\lib\site-packages\comtypes\client__init__.py", line 188, in _manage obj = GetBestInterface(obj) File "D:\projects\P\AlphaCapture\wechatcapture\service\venv\lib\site-packages\comtypes\client\init__.py", line 112, in GetBestInterface interface = getattr(mod, itf_name) AttributeError: module 'comtypes.gen.WeChatRobotCOMLib' has no attribute 'IRobotEvent'

Wechat 3.7.0.30,python 版本 3.8 求大佬指导可能是什么问题?

ljc545w commented 2 years ago

如果以前使用过旧版本,需要先清理下comtypes.gen目录中的缓存。comtypes有时会有延迟。

CharlesLi114 commented 2 years ago

用tag里面的zip + test 放在同级目录,somehow works。可能是延时?

ljc545w commented 2 years ago

有使用过老版本的com注册过没有,有的话,清理下python site-packages中的comtypes.gen目录。