sikuli中的org.sikuli.api.ScreenRegion错误是什么意思?

时间:2014-09-24 19:21:04

标签: python sikuli

我使用的是Python 2.7,我已经从here安装了sikuli_cpython。

我有一个简单的脚本:

from sikuli.sikuli import *

symbol_image ='symbol.jpg'
t = find(symbol_image)
print t
click(t)

当我运行它时,我收到以下错误消息:

File "C:\Projects\sikuli1.py", line 112, in <module>
    click(t)
  File "C:\Python27\lib\site-packages\sikuli-0.1-py2.7.egg\sikuli\sikuli.py", line 61, in click
    loc = Pattern(target_string).getLocation()
  File "C:\Python27\lib\site-packages\sikuli-0.1-py2.7.egg\sikuli\sikuli.py", line 139, in getLocation
    t = self.getTarget()
  File "C:\Python27\lib\site-packages\sikuli-0.1-py2.7.egg\sikuli\sikuli.py", line 135, in getTarget
    return self._get_target_from_string(self.target_string)
  File "C:\Python27\lib\site-packages\sikuli-0.1-py2.7.egg\sikuli\sikuli.py", line 148, in _get_target_from_string
    target_file_loc = self._find_local_file(target_string)
  File "C:\Python27\lib\site-packages\sikuli-0.1-py2.7.egg\sikuli\sikuli.py", line 162, in _find_local_file
    poss_relative_path = os.path.join(os.getcwd(), target_string)
  File "C:\Python27\lib\ntpath.py", line 73, in join
    elif isabs(b):
  File "C:\Python27\lib\ntpath.py", line 57, in isabs
    s = splitdrive(s)[1]
  File "C:\Python27\lib\ntpath.py", line 125, in splitdrive
    if p[1:2] == ':': 
TypeError: 'org.sikuli.api.ScreenRegion' object has no attribute '__getitem__'

我知道sikuli用于jython。我已经使用了sikuli ide,我已经安装了jython 2.5.3。虽然,我在使用jython easy_install sikuli时遇到了问题。

1 个答案:

答案 0 :(得分:0)

我没有sikuli_cpython的专业知识。但是从sikuli ide(jython)的角度来看,对象symbol_image没有被正确声明。 find和click函数需要一个Pattern对象,你声明它的方式似乎是一个字符串。 尝试:

symbol_image = Pattern('symbol.jpg')

但您可能需要提供图像目录的完整路径,并使用.png扩展名。