Calling a click from a sub-routine causes an exception.

Asked by Mark McGuinn on 2020-01-05

Below is a simple test case which shows the problem. The click command if called on its own works fine, however if you try to call it from a sub-routine then you get an exception saying the image file could not be found

result = test_auction(1000,1000)
print result

the called routine:

def test_auction(high_bid,low_bid):


The error message:

[error] script [ ttauction ] stopped with error in line 2
[error] FindFailed ( 1575297163479-1.png: (37x31) in R[0,0 1680x1050]@S(0) )
[error] --- Traceback --- error source first
line: module ( function ) statement
5: Sauction ( test_auction ) click(Pattern("1575297163479-1.png").similar(0.80))
2: main ( <module> ) result = test_auction(1000,1000)
[error] --- Traceback --- end --------------

This is Sikuli 2.0.1 on Windows 10 (64 bit). I have also tried without the similar option and that makes no difference . I also tried a sub-routine with o parameters and again no difference.

The image does exist before the call is made there is no waiting for an image to appear. The code runs ok on the same page if not called from the subroutine.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

should be a question first

RaiMan (raimund-hocke) said : #2

FindFailed means, that the image is not visible on the screen in that moment.

Please check this first.

Mark McGuinn (mmcguinn) said : #4

This is marked as answered but the bug remains. What do I need to do to confirm it is a bug?

RaiMan (raimund-hocke) said : #5

this works as it should:

img = "img.png"

def someSub():


So this is surely not a bug.

There must be other reasons, that it fails.
Make a compact sample like mine above and try to reproduce.

Mark McGuinn (mmcguinn) said : #6

Here is the simplest test case:

result = test()
print result

which calls:

def test():

The image it is calling is just the "Sikuli" link on the page above. The error as reported is:

[error] ImagePath: find: not there: 1578666326196.png
[error] script [ call_bug_routine ] stopped with error in line 1
[error] FindFailed ( 1578666326196.png not loaded )
[error] --- Traceback --- error source first
line: module ( function ) statement
2: bug_routine ( test ) click("1578666326196.png")
1: main ( <module> ) resu8lt = test()
[error] --- Traceback --- end --------------

Mark McGuinn (mmcguinn) said : #7

HI, I was wonderng if anyone has had the time to look at this issue. If they have is it reproducible from the simple example above?

Mark McGuinn (mmcguinn) said : #8

Looking into the issue to try and find a workaround I discovered that the image path does not contain the sub-routine folder as it apparently should. If you manually add the directory to the default image path then the image that is being looked for is found.

RaiMan (raimund-hocke) said : #9

- I discovered that the image path does not contain the sub-routine folder as it apparently should
This can only mean, that the function is not in the same file as the calling statement.

Did you use
from subScript import *
print test()

having a

def test():

and did you create subScript.sikuli regularly in the IDE including the image capture?

All this information was missing along your posts. sorry.

Mark McGuinn (mmcguinn) said : #10

My apologies, I did not do a specific import of the routines, I thought that they would be imported automatically as outlined in the Documentation

Sikuli automatically finds other Sikuli scripts in the same directory, when they are imported

I guess I misunderstood what the documentation was saying.

Launchpad Janitor (janitor) said : #11

This question was expired because it remained in the 'Open' state without activity for the last 15 days.