So, I am new to sikuli coding, I do not have much experience with python either, so for many of you this might be a silly question. My problem is that I am trying to pause the program for x seconds. I have tried these 2 ways but every time I am getting an error. Here is what I have tried to do:
import time
time.sleep(10)
Error I am getting: [error] SyntaxError ( "no viable alternative at input 'time'", )
=======
sleep(10)
Error I am getting: [error] SyntaxError ( "no viable alternative at input 'sleep'", )
I hope that someone can help me with my silly problem. I would really appreciate :) (also, sorry for the Bad English)
Thanks in advance!
sleep(10)
is 100% correct for sikuli IDE for how to get your program to pause for 10 seconds, so here are a few thoughts:
That error can crop up for lots of different reasons, but a really common one--in Python, white space DOES matter, and indentation is often a huge culprit for errors like this. In the sikuli IDE, your loops have to be indented exactly 4 spaces ( = 1 tab), any more or less will throw this error. You can also check for some missing syntax like apostrophes or brackets, sometimes in the line preceding the one that's throwing the error.
In this particular case, sometimes the import statement is finicky. You could try from time import *
instead of just import time
. They're supposed to be equal, but they seem to behave differently to me sometimes.
If you're importing the 'time' module just to use in functions like sleep(i)
and wait(i)
, then the import is unnecessary, because those functions just require you to supply an integer i
that represents a number of seconds, and they do the rest as part of their built-in functionality.
Finally, if you find that 'import time' is the problem, I have found that the Sikuli IDE does not have native access to all of the possible modules to import. I have had lots of success with the datetime module, but I have never tried just the time module. You might switch to 'import datetime' and see if that helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With