Python-UIAutomation-for-Windows
Python-UIAutomation-for-Windows copied to clipboard
module "comtypes.gen.UIAutomationClient" has no attribute "IUIAutomation"
window = uiautomation.WindowControl(Name="Remote Desktop Connection", searchDepth=1) print(window.Exists()) 上述代码在pycharm里执行成功,用pyinstaller -F 打包后的exe在当前打包的机器上执行也成功, 但把exe放到另一台没有安装Python的机器上时就提示标题所述的异常。 uiautomation version = 2.0.3, 系统是win10 RS5 5855 in Exists 7678 in FindControl 7460 in GetRootControl 51 in instance 57 in init
有几个py文件是第一次用的时候由comtypes动态生成的,在site-packages\comtypes\gen目录 在我电脑上是 C:\Python37\Lib\site-packages\comtypes\gen ├──UIAutomationClient.py ├──_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.py └──init.py IUIAutomation在_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.py里。 不同操作系统版本生成的py文件内容可能有点不同,比如TextPattern2等几个Pattern在Windows7上是没有的,如果你用到的话必须在Windows10上运行动态生成,如果不用Windows10上特有的Pattern,Windows7上生成的py放在Windows10上应该也能用(没有实际测试过)。
我没用过pyinstaller, 我猜你可能需要在Windows10上用pyinstaller把这几个动态生成的文件打包进去。
请问有解决吗,遇到了同样的问题,pyinstaller该如何能打包进去

Did you ever figure out this issue?