无法在Windows10上导入pywinauto

我安装pywinauto使用pip install pywinauto.

操作系统:Windows 10

蟒蛇:3.6.2

当我运行python并尝试 import 时pywinauto,出现错误:

Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pywinauto.application import Application
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagespywinauto__init__.py", line 89, in <module>
    from . import findwindows
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagespywinautofindwindows.py", line 42, in <module>
    from . import controls
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagespywinautocontrols__init__.py", line 36, in <module>
    from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagespywinautocontrolsuiawrapper.py", line 47, in <module>
    from ..uia_defines import IUIA
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagespywinautouia_defines.py", line 181, in <module>
    pattern_ids = _build_pattern_ids_dic()
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagespywinautouia_defines.py", line 169, in _build_pattern_ids_dic
    if hasattr(IUIA().ui_automation_client, cls_name):
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagespywinautouia_defines.py", line 50, in __call__
    cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagespywinautouia_defines.py", line 60, in __init__
    self.UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll')
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagescomtypesclient_generate.py", line 118, in GetModule
    mod = _CreateWrapper(tlib, pathname)
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagescomtypesclient_generate.py", line 183, in _CreateWrapper
    generate_module(tlib, ofi, pathname)
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagescomtypestoolstlbparser.py", line 750, in generate_module
    gen.generate_code(list(items.values()), filename=pathname)
  File "C:UsersJohnAppDataRoamingPythonPython36site-packagescomtypestoolscodegenerator.py", line 261, in generate_code
    tlib_mtime = os.stat(self.filename).st_mtime
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'UIAutomationCore.dll'

任何想法如何解决这一问题?

回答

我今天遇到了同样的问题并通过pip install comtypes==1.1.7. 它是由comtypes库引起的,库在 12 月 26 日发布了新版本 1.1.8。降级到以前的版本,现在运行良好。

  • Now it is fixed in `comtypes==1.1.9`. Please check.

以上是无法在Windows10上导入pywinauto的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>