python - 无法在 Windows 10 上导入 pywinauto
问题描述
我pywinauto
使用pip install pywinauto
.
操作系统:Windows 10
蟒蛇:3.6.2
当我运行python
并尝试 importpywinauto
时,出现错误:
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:\Users\John\AppData\Roaming\Python\Python36\site-packages\pywinauto\__init__.py", line 89, in <module>
from . import findwindows
File "C:\Users\John\AppData\Roaming\Python\Python36\site-packages\pywinauto\findwindows.py", line 42, in <module>
from . import controls
File "C:\Users\John\AppData\Roaming\Python\Python36\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:\Users\John\AppData\Roaming\Python\Python36\site-packages\pywinauto\controls\uiawrapper.py", line 47, in <module>
from ..uia_defines import IUIA
File "C:\Users\John\AppData\Roaming\Python\Python36\site-packages\pywinauto\uia_defines.py", line 181, in <module>
pattern_ids = _build_pattern_ids_dic()
File "C:\Users\John\AppData\Roaming\Python\Python36\site-packages\pywinauto\uia_defines.py", line 169, in _build_pattern_ids_dic
if hasattr(IUIA().ui_automation_client, cls_name):
File "C:\Users\John\AppData\Roaming\Python\Python36\site-packages\pywinauto\uia_defines.py", line 50, in __call__
cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
File "C:\Users\John\AppData\Roaming\Python\Python36\site-packages\pywinauto\uia_defines.py", line 60, in __init__
self.UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll')
File "C:\Users\John\AppData\Roaming\Python\Python36\site-packages\comtypes\client\_generate.py", line 118, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "C:\Users\John\AppData\Roaming\Python\Python36\site-packages\comtypes\client\_generate.py", line 183, in _CreateWrapper
generate_module(tlib, ofi, pathname)
File "C:\Users\John\AppData\Roaming\Python\Python36\site-packages\comtypes\tools\tlbparser.py", line 750, in generate_module
gen.generate_code(list(items.values()), filename=pathname)
File "C:\Users\John\AppData\Roaming\Python\Python36\site-packages\comtypes\tools\codegenerator.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
. 它是由12 月 26 日发布新版本 1.1.8的comtypes库引起的。降级到以前的版本,现在运行良好。
推荐阅读
- java - 如何将java类字段转换为字符串值数组
- c++ - 如何比在 C++ 中使用 qsort 更快地对一百万个数字进行分组?
- hadoop - 如何从hadoop将数据导出到大型机
- c# - 将数据从数据库拖到列表框
- java - 为什么特定 Guava Stopwatch.elapsed() 调用比其他调用晚得多?(在帖子中输出)
- database - 我在哪里可以找到一些示例价目表数据库?
- python - 如何在 sphinx 中更改 pybtex 引用的样式
- .net - 为什么 CORS 不适用于此配置?
- excel - 如何根据 Excel 中的 ID 列复制和同步表?
- excel - “this”表上的单元格具有“that”表上的单元格的单元格地址。我正在尝试更改“那个”表上单元格的内容