我试图在Windows 10计算机上使用python 3.5.4,
执行以下命令from pywinauto.application import Application
以下是我收到的错误
Traceback (most recent call last):
File "C:/Users/bizact/Desktop/PSAV/test.py", line 1, in <module>
from pywinauto.application import Application
File "C:\Program Files\Python35\lib\site-packages\pywinauto\__init__.py", line 72, in <module>
from . import findwindows
File "C:\Program Files\Python35\lib\site-packages\pywinauto\findwindows.py", line 42, in <module>
from . import controls
File "C:\Program Files\Python35\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:\Program Files\Python35\lib\site-packages\pywinauto\controls\uiawrapper.py", line 46, in <module>
from ..uia_defines import IUIA
File "C:\Program Files\Python35\lib\site-packages\pywinauto\uia_defines.py", line 35, in <module>
import comtypes.client
File "C:\Program Files\Python35\lib\site-packages\comtypes\client\__init__.py", line 33, in <module>
gen_dir = _find_gen_dir()
File "C:\Program Files\Python35\lib\site-packages\comtypes\client\_code_cache.py", line 71, in _find_gen_dir
result = os.path.abspath(gen_path[-1])
IndexError: list index out of range
有没有办法解决这个问题?
答案 0 :(得分:1)
尝试使用管理特权运行脚本。仅查看回溯,就好像pywinauto import尝试写入了一些缓存文件,但后来却找不到了,并且由于权限的原因,脚本通常无法写入文件。如果上述方法无效,请尝试在其他位置安装python(具有完全特权的C:/ Python以便隔离问题)
答案 1 :(得分:0)
这是商品问题。即将修复(编辑:在comtypes==1.1.7
中进行了修复)。您可以降级为以前的版本之一:pip install comtypes==1.1.2
。或按照Rodolfo的建议以Administrator身份运行脚本(禁用UAC可能无济于事,需要通过弹出菜单明确说“以Administrator身份运行”)。