运行使用pywinauto的脚本时出现错误 [英] Getting error while running a script which uses pywinauto

查看:294
本文介绍了运行使用pywinauto的脚本时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我导入pywinauto时,我都会遇到以下错误"追溯(最近一次通话):WINFUNCTYPE中的第123行的文件"D:\ Python \ Python38 \ lib \ ctypes_init_.py"返回_win_functype_cache [(restype,argtypes,标志)]KeyError:(,(,,,),0)

Whenever I import pywinauto I am getting below error " Traceback (most recent call last): File "D:\Python\Python38\lib\ctypes_init_.py", line 123, in WINFUNCTYPE return _win_functype_cache[(restype, argtypes, flags)] KeyError: (, (, , ), 0)

在处理上述异常期间,发生了另一个异常:

During handling of the above exception, another exception occurred:

回溯(最近通话最近):在第3行中输入文件"C:/Users/tejaw/PycharmProjects/xxxxxxxx/Sample.py"导入pywinauto文件"D:\ Python \ Python38 \ lib \ site-packages \ pywinauto_init_.py",第89行,在从 .导入findwindows文件"D:\ Python \ Python38 \ lib \ site-packages \ pywinauto \ findwindows.py",第42行,在从 .进口管制文件"D:\ Python \ Python38 \ lib \ site-packages \ pywinauto \ controls_init_.py",第36行,在从 .导入uiawrapper#在后端注册"uia"(在uiawrapper模块的末尾)文件"D:\ Python \ Python38 \ lib \ site-packages \ pywinauto \ controls \ uiawrapper.py",第47行,在从..uia_defines导入IUIA文件"D:\ Python \ Python38 \ lib \ site-packages \ pywinauto \ uia_defines.py",第181行,位于pattern_ids = _build_pattern_ids_dic()_build_pattern_ids_dic中的第169行的文件"D:\ Python \ Python38 \ lib \ site-packages \ pywinauto \ uia_defines.py"如果hasattr(IUIA().ui_automation_client,cls_name):通话中第50行的文件"D:\ Python \ Python38 \ lib \ site-packages \ pywinauto \ uia_defines.py"cls._instances [cls] =超级(_Singleton,cls).call(* args,** kwargs)初始化文件"D:\ Python \ Python38 \ lib \ site-packages \ pywinauto \ uia_defines.py",第60行self.UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll')GetModule中的第110行的文件"D:\ Python \ Python38 \ lib \ site-packages \ comtypes \ client_generate.py"mod = _CreateWrapper(tlib,路径名)_CreateWrapper中的第184行的文件"D:\ Python \ Python38 \ lib \ site-packages \ comtypes \ client_generate.py"mod = _my_import(全名)在my_import中的文件"D:\ Python \ Python38 \ lib \ site-packages \ comtypes \ client_generate.py",第24行返回import(全名,globals(),locals(),['DUMMY'])第1931行的文件"D:\ Python \ Python38 \ lib \ site-packages \ comtypes \ gen_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.py"IUIAutomation.methods = [setattr中的文件"D:\ Python \ Python38 \ lib \ site-packages \ comtypes_init.py",第329行self.make_methods(值)在make_methods中的行698中的文件"D:\ Python \ Python38 \ lib \ site-packages \ comtypes_init.py"原型= WINFUNCTYPE(restype,* argtypes)WINFUNCTYPE中的文件"D:\ Python \ Python38 \ lib \ ctypes_init.py",第125行WinFunctionType(_CFuncPtr)类:TypeError:argtypes中的第2项按值传递并集,该值不受支持."

Traceback (most recent call last): File "C:/Users/tejaw/PycharmProjects/xxxxxxxx/Sample.py", line 3, in import pywinauto File "D:\Python\Python38\lib\site-packages\pywinauto_init_.py", line 89, in from . import findwindows File "D:\Python\Python38\lib\site-packages\pywinauto\findwindows.py", line 42, in from . import controls File "D:\Python\Python38\lib\site-packages\pywinauto\controls_init_.py", line 36, in from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module) File "D:\Python\Python38\lib\site-packages\pywinauto\controls\uiawrapper.py", line 47, in from ..uia_defines import IUIA File "D:\Python\Python38\lib\site-packages\pywinauto\uia_defines.py", line 181, in pattern_ids = _build_pattern_ids_dic() File "D:\Python\Python38\lib\site-packages\pywinauto\uia_defines.py", line 169, in _build_pattern_ids_dic if hasattr(IUIA().ui_automation_client, cls_name): File "D:\Python\Python38\lib\site-packages\pywinauto\uia_defines.py", line 50, in call cls._instances[cls] = super(_Singleton, cls).call(*args, **kwargs) File "D:\Python\Python38\lib\site-packages\pywinauto\uia_defines.py", line 60, in init self.UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll') File "D:\Python\Python38\lib\site-packages\comtypes\client_generate.py", line 110, in GetModule mod = _CreateWrapper(tlib, pathname) File "D:\Python\Python38\lib\site-packages\comtypes\client_generate.py", line 184, in _CreateWrapper mod = _my_import(fullname) File "D:\Python\Python38\lib\site-packages\comtypes\client_generate.py", line 24, in my_import return import(fullname, globals(), locals(), ['DUMMY']) File "D:\Python\Python38\lib\site-packages\comtypes\gen_944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0.py", line 1931, in IUIAutomation.methods = [ File "D:\Python\Python38\lib\site-packages\comtypes_init.py", line 329, in setattr self.make_methods(value) File "D:\Python\Python38\lib\site-packages\comtypes_init.py", line 698, in make_methods prototype = WINFUNCTYPE(restype, *argtypes) File "D:\Python\Python38\lib\ctypes_init.py", line 125, in WINFUNCTYPE class WinFunctionType(_CFuncPtr): TypeError: item 2 in argtypes passes a union by value, which is unsupported. "

请帮助我.

推荐答案

这是Python 2.7.6和3.8.1中的Python错误.请重新安装Python 3.7.7+或3.8.2 +.

This is Python bug in Python 2.7.6 and 3.8.1. Please do clean install of Python 3.7.7+ or 3.8.2+.

此问题的完整历史记录在这里: https://github.com/pywinauto/pywinauto/issues/868

Full history of the issue is here: https://github.com/pywinauto/pywinauto/issues/868

这是libffi中缺少的用于按值传递并集的功能.ctypes使用libffi在运行时解析调用约定.由于缺少功能,Python Core开发人员决定禁止此选项.但是,错误的决定破坏了Windows上的许多用户.因此,错误的补丁已在Python 3.7.7/3.8.2中恢复.

This is a missing feature in libffi for passing union by value. libffi is used by ctypes for resolving calling convention at runtime. Python Core developers decided to prohibit this option due to missing feature. But it was wrong decision that broke a lot of users on Windows. So the wrong patch was reverted in Python 3.7.7 / 3.8.2.

这篇关于运行使用pywinauto的脚本时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆