sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #26011
Re: [Question #246338]: NameError when importing sikuli modules
Question #246338 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/246338
Jonas Maurer posted a new comment:
I had the same Issue:
to demonstrate the problem I created two sikuli files, both containing
one line only:
module:
wait(1)
root:
import file1
If I run "module" the IDE waits one second as expected
If I run "root" the IDE it returns a error message: "name wait is not
defined"
when adding "from sikuli import *" as first line to module:
from sikuli import *
wait(1)
then it works. So I conclude that sikuli is imported in the main file
that the IDE executes by default, but not to imported modules. (which is
confusing to beginners when importing working scripts into others where
they suddenly cease to work)
about bilel's comment about refreshing the IDE
refreshing the IDE is not going to magically solve the problem above or any other problems
the thing is, if you run your main file (e.g. root) it imports the used modules on the first time.
It will not import them the second time unless you refresh the IDE.
so if you run your main file, then modify your modules, and then run your main file again, it will not rerun the modules, but work from memory, the modules work as if they were not changed after you run the file the first time.
That IDE behaviour is also rather confusing when getting started with sikuli, and have little or no experience with jython.
TLDR: add "from sikuli import *" to every sikuli script first line and
reload IDE every time a module has been modified.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.