← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #230599]: How to import Sikuli in Jython?

 

Question #230599 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/230599

RaiMan proposed the following answer:
Based on the mentioned configuration I suppose you are using Sikuli-API
1.0.0

Roman's suggestion should work if you want to use jython from command
line (besides the fact, that you have to have a ref to Sikuli's libs
folder in system path at runtime)

If you want to setup a project in Netbeans 7.3 with the Python plugin,
you have to first add a ref to sikuli-script.jar TO THE END of the class
path of your used Jython config (project props -> Python tab -> manage
... button)

Second you need a ref to .../sikuli-script.jar/Lib in your sys.path at
runtime.

1. option (in the script):
import sys
lib = "... path-to-your... /sikuli-script.jar/Lib"
sys.path.append(lib)
from sikuli import *
popup("hallo")

2. option (copy folder .../sikuli-script.jar/Lib/sikuli to Jython's Lib/site-packages)
for this you have to unjar sikuli-script.jar, to get to the mentioned folder
since site-packages is in the standard sys.path, this should work:
from sikuli import *
popup("hallo")

3. option (add ... path-to-your... /sikuli-script.jar/Lib to the Netbeans property file)
Since it is still not possible to do this in the properties dialog (not possible to step inside a jar), you can do this trick:
- add ... path-to-your... /sikuli-script.jar TO THE END of the Jython's config PythonPath
- close Netbeans
- edit Netbeans config file and add /Lib to the existing line
- restart Netbeans and check the properties

again this should work then:
from sikuli import *
popup("hallo")

BE AWARE: in all cases you need the ref to Sikuli's libs folder in the
system path at runtime.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.