getting error while use python language inside sikuli

Asked by Aneesh t a

I am new to sikuli, while i am trying to use python language inside sikuli its not working ,please let me know what all things need to be import before using python.please find below my code

import os.path
import java.lang
import org.python
reg=Region(281,234,301,302)
img=capture(reg)
if exists(img):
print "exists"

[error] Stopped [error] An error occurs at line 8 [error] Error message: SyntaxError: ("mismatched input 'print' expecting INDENT", ('C:\\DOCUME~1\\393896\\LOCALS~1\\Temp\\sikuli-tmp4781017043883738455.py', 8, 0, 'print img, "finally came up"\n'))

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

When using the Sikuli IDE you only need to import modules, whose features you want to use later on.

sys and time are already imported, so this is possible without importing:
print sys.path
print time.time()

your problem:

reg=Region(281,234,301,302)
img=capture(reg)
if exists(img):
    print "exists"

To show, which statements make up a block, Python uses indentation (use one tab for one level)/dedentation (use shift-tab). This has to be done after if/elif/else, while, for, try/except, def and some more control statements.

To write more complex Sikuli scripts, you need some basic knowledge of Python.

Can you help with this problem?

Provide an answer of your own, or ask Aneesh t a for more information if necessary.

To post a message you must log in.