'windows xp import pywinauto error

  1. use pywinauto in windows7 64 bit, work fine
  2. use it in windows xp, met issue as below. Tried python3.4.4+pywinauto0.6.3, python2.7.14+pywinauto0.6.3 has the same issue.

    import pywinauto
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Python27\lib\site-packages\pywinauto\__init__.py", line 40, in <module>
      from . import findwindows
      File "C:\Python27\lib\site-packages\pywinauto\findwindows.py", line 42, in <module>
        from . import controls
      File "C:\Python27\lib\site-packages\pywinauto\controls\__init__.py", line 36,in <module>
        from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
      File "C:\Python27\lib\site-packages\pywinauto\controls\uiawrapper.py", line 44, in <module>
      from ..uia_defines import IUIA
      File "C:\Python27\lib\site-packages\pywinauto\uia_defines.py", line 175, in <module>
        pattern_ids = _build_pattern_ids_dic()
      File "C:\Python27\lib\site-packages\pywinauto\uia_defines.py", line 163, in _build_pattern_ids_dic
        if hasattr(IUIA().ui_automation_client, cls_name):
      File "C:\Python27\lib\site-packages\pywinauto\uia_defines.py", line 50, in __call__
        cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
      File "C:\Python27\lib\site-packages\pywinauto\uia_defines.py", line 60, in __init__
        self.UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll')
      File "C:\Python27\lib\site-packages\comtypes\client\_generate.py", line 97, in GetModule
        tlib = comtypes.typeinfo.LoadTypeLibEx(tlib)
      File "C:\Python27\lib\site-packages\comtypes\typeinfo.py", line 485, in LoadTypeLibEx
        _oleaut32.LoadTypeLibEx(c_wchar_p(szFile), regkind, byref(ptl))
      File "_ctypes/callproc.c", line 950, in GetResult
    WindowsError: [Error -2147312566] Error loading type library/DLL
    

I check another same topic, install .netframework 3.5 or uninstall pip uninstall comtypes, cannot resolve the problem. Need a more experienced person to help.



Solution 1:[1]

This is known issue. Should work on WinVista+. Or you can use pip install pywinauto==0.5.4 though UIA backend is absent here and coding style is pretty old (may not match some docs).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vasily Ryabov