importing Sikuli in Jython - Jedit IDE

Asked by vidya rajagopal

Hi ,

I am using jEdit Jyhthon Interpreter plugin 1.0 ( Jython vesrion 2.5.2). I would like to import Sikuli modules such as capture, click clickall, dragdrop etc into Jyhthon script.
Could you please let me know how to achive this .

Thanks
vidya

Question information

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

Just put
path-to-sikuli-script.jar
into the class path of Jedit.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

But you might get into conflicts with Sikuli's built-in Jython, if you try to use the Jython layer of Sikuli
(sikuli-script.jar/Lib/sikuli).

--- sikuli-script.jar/Lib must be in Jythons sys.path
--- from sikuli import * must be in your script

If this leads to weird situations, you have to take the folder sikuli-script.jar/Lib/sikuli out of the jar and place it into the site-packages directory of your Jython installation. then it is only

--- from sikuli import * must be in your script

But in all cases:
path-to-sikuli-script.jar must be in the class path of Jedit.

Revision history for this message
vidya rajagopal (vidya-rajagopal) said :
#3

Thanks for the help .

I have updated the path . But after that what? I am new to Jython also . Can you pls give me the import syntax for this.

Thanks
Vidya

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of RaiMan
Sent: Tuesday, June 12, 2012 12:51 PM
To: Rajagopal, Vidya
Subject: Re: [Question #200162]: importing Sikuli in Jython - Jedit IDE

Your question #200162 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/200162

    Status: Open => Answered

RaiMan proposed the following answer:
Just put
path-to-sikuli-script.jar
into the class path of Jedit.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/sikuli/+question/200162/+confirm?answer_id=0

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/sikuli/+question/200162

You received this question notification because you asked the question.

________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________

www.accenture.com

Revision history for this message
RaiMan (raimund-hocke) said :
#4

see comment #2

Revision history for this message
vidya rajagopal (vidya-rajagopal) said :
#5

Sorry for asking dum question again .
I have Sikuli Exe and I don't find " sikuli-script.jar/Lib/sikuli" but the folder where I have the Sikuli exe has the sikuli-script.jar file.

So I don't undersand when you say

" If this leads to weird situations, you have to take the folder sikuli-
script.jar/Lib/sikuli out of the jar and place it into the site-packages
directory of your Jython installation. then it is only"

Could you please elaborate on this as to how I can extract the file from jar?

Thanks
Vidya

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of RaiMan
Sent: Tuesday, June 12, 2012 1:01 PM
To: Rajagopal, Vidya
Subject: Re: [Question #200162]: importing Sikuli in Jython - Jedit IDE

Your question #200162 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/200162

RaiMan posted a new comment:
But you might get into conflicts with Sikuli's built-in Jython, if you try to use the Jython layer of Sikuli
(sikuli-script.jar/Lib/sikuli).

--- sikuli-script.jar/Lib must be in Jythons sys.path
--- from sikuli import * must be in your script

If this leads to weird situations, you have to take the folder sikuli-
script.jar/Lib/sikuli out of the jar and place it into the site-packages
directory of your Jython installation. then it is only

--- from sikuli import * must be in your script

But in all cases:
path-to-sikuli-script.jar must be in the class path of Jedit.

--
You received this question notification because you asked the question.

________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________

www.accenture.com

Revision history for this message
RaiMan (raimund-hocke) said :
#6

look in the docs:
http://sikuli.org/docx/faq/040-other-ide.html#how-to-use-sikuli-together-with-other-ide-s

Though this is special for NetBeans and Eclipse, all your questions are answered somehow and you might get a better insight.

Revision history for this message
vidya rajagopal (vidya-rajagopal) said :
#7

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of RaiMan
Sent: Tuesday, June 12, 2012 1:26 PM I did upadte the path of sikuli script jar file path
C:\Program Files\Sikuli X\sikuli-script.jar\Lib\ in Jedit
Now when I use " from sikuli.Sikuli import *" I get the below error . Can you let me know where I might be going wrong
------------------------------------
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "D:\Documents and Settings\vidya.rajagopal\.jedit\jars\JythonInterpreter.jar\jython\PyParser.py", line 28, in <module>
ImportError: No module named sidekick
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\__init__.py", line 3, in <module>
  File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\Sikuli.py", line 22, in <module>
java.lang.NoClassDefFoundError: Could not initialize class org.sikuli.script.Finder

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Unknown Source)

        at org.python.core.Py.loadAndInitClass(Py.java:895)

        at org.python.core.Py.findClassInternal(Py.java:830)

        at org.python.core.Py.findClassEx(Py.java:881)

        at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:133)

        at org.python.core.packagecache.PackageManager.findClass(PackageManager.java:28)

        at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:122)

        at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)

        at org.python.core.PyObject.__findattr__(PyObject.java:863)

        at org.python.core.imp.import_name(imp.java:849)

        at org.python.core.imp.importName(imp.java:884)

        at org.python.core.ImportFunction.__call__(__builtin__.java:1220)

        at org.python.core.PyObject.__call__(PyObject.java:357)

        at org.python.core.__builtin__.__import__(__builtin__.java:1173)

        at org.python.core.imp.importFromAs(imp.java:978)

        at org.python.core.imp.importFrom(imp.java:954)

        at sikuli.Sikuli$py.f$0(C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\Sikuli.py:211)

        at sikuli.Sikuli$py.call_function(C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\Sikuli.py)

        at org.python.core.PyTableCode.call(PyTableCode.java:165)

        at org.python.core.PyCode.call(PyCode.java:18)

        at org.python.core.imp.createFromCode(imp.java:386)

        at org.python.core.util.importer.importer_load_module(importer.java:109)

        at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161)

        at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)

        at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)

        at org.python.core.imp.loadFromLoader(imp.java:513)

        at org.python.core.imp.find_module(imp.java:467)

        at org.python.core.PyModule.impAttr(PyModule.java:100)

        at org.python.core.imp.import_next(imp.java:715)

        at org.python.core.imp.import_name(imp.java:824)

        at org.python.core.imp.importName(imp.java:884)

        at org.python.core.ImportFunction.__call__(__builtin__.java:1220)

        at org.python.core.PyObject.__call__(PyObject.java:357)

        at org.python.core.__builtin__.__import__(__builtin__.java:1173)

        at org.python.core.imp.importAll(imp.java:998)

        at sikuli$py.f$0(C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\__init__.py:3)

        at sikuli$py.call_function(C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\__init__.py)

        at org.python.core.PyTableCode.call(PyTableCode.java:165)

        at org.python.core.PyCode.call(PyCode.java:18)

        at org.python.core.imp.createFromCode(imp.java:386)

        at org.python.core.util.importer.importer_load_module(importer.java:109)

        at org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161)

        at org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown Source)

        at org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)

        at org.python.core.imp.loadFromLoader(imp.java:513)

        at org.python.core.imp.find_module(imp.java:467)

        at org.python.core.imp.import_next(imp.java:713)

        at org.python.core.imp.import_name(imp.java:824)

        at org.python.core.imp.importName(imp.java:884)

        at org.python.core.ImportFunction.__call__(__builtin__.java:1220)

        at org.python.core.PyObject.__call__(PyObject.java:357)

        at org.python.core.__builtin__.__import__(__builtin__.java:1173)

        at org.python.core.imp.importAll(imp.java:998)

        at org.python.pycode._pyx83.f$0(<console>:1)

        at org.python.pycode._pyx83.call_function(<console>)

        at org.python.core.PyTableCode.call(PyTableCode.java:165)

        at org.python.core.PyCode.call(PyCode.java:18)

        at org.python.core.Py.runCode(Py.java:1261)

        at org.python.core.Py.exec(Py.java:1305)

        at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)

        at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89)

        at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70)

        at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:46)

        at jython.JeditConsole.pushLine(JeditConsole.java:62)

        at jython.LineCommand.doExecute(JeditConsole.java:195)

        at jython.AbstractCommand.execute(JeditConsole.java:145)

        at jython.JythonExecutor.run(JythonExecutor.java:335)

        at java.lang.Thread.run(Unknown Source)

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: Could not initialize class org.sikuli.script.Finder
------------------------------------------------------------------
To: Rajagopal, Vidya
Subject: Re: [Question #200162]: importing Sikuli in Jython - Jedit IDE

Your question #200162 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/200162

    Status: Open => Answered

RaiMan proposed the following answer:
look in the docs:
http://sikuli.org/docx/faq/040-other-ide.html#how-to-use-sikuli-together-with-other-ide-s

Though this is special for NetBeans and Eclipse, all your questions are
answered somehow and you might get a better insight.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/sikuli/+question/200162/+confirm?answer_id=5

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/sikuli/+question/200162

You received this question notification because you asked the question.

________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________

www.accenture.com

Revision history for this message
RaiMan (raimund-hocke) said :
#8

--- did upadte the path of sikuli script jar file path C:\Program Files\Sikuli X\sikuli-script.jar\Lib\ in Jedit
This contains the Jython stuff and is exactly what might lead to problems (see comment #2).

To overcome this make a script containing:

for e in sys.path: print e

So you can see, what is in sys.path, when your script is running.

Is sikuli-script.jar in Jedit's class path?

Revision history for this message
vidya rajagopal (vidya-rajagopal) said :
#9

Yes I am still facing error in the import sikuli statement

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of vidya rajagopal
Sent: Tuesday, June 12, 2012 3:16 PM
To: Rajagopal, Vidya
Subject: Re: [Question #200162]: importing Sikuli in Jython - Jedit IDE

Your question #200162 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/200162

    Status: Answered => Open

You are still having a problem:

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of RaiMan
Sent: Tuesday, June 12, 2012 1:26 PM I did upadte the path of sikuli script jar file path
C:\Program Files\Sikuli X\sikuli-script.jar\Lib\ in Jedit
Now when I use " from sikuli.Sikuli import *" I get the below error . Can you let me know where I might be going wrong
------------------------------------
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "D:\Documents and Settings\vidya.rajagopal\.jedit\jars\JythonInterpreter.jar\jython\PyParser.py", line 28, in <module>
ImportError: No module named sidekick
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\__init__.py", line 3, in <module>
  File "C:\Program Files\Sikuli X\sikuli-script.jar\Lib\sikuli\Sikuli.py", line 22, in <module>
java.lang.NoClassDefFoundError: Could not initialize class org.sikuli.script.Finder

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Unknown Source)

        at org.python.core.Py.loadAndInitClass(Py.java:895)

        at org.python.core.Py.findClassInternal(Py.java:830)

        at org.python.core.Py.findClassEx(Py.java:881)

        at
org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:133)

        at
org.python.core.packagecache.PackageManager.findClass(PackageManager.java:28)

        at
org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:122)

        at
org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)

        at org.python.core.PyObject.__findattr__(PyObject.java:863)

        at org.python.core.imp.import_name(imp.java:849)

        at org.python.core.imp.importName(imp.java:884)

        at
org.python.core.ImportFunction.__call__(__builtin__.java:1220)

        at org.python.core.PyObject.__call__(PyObject.java:357)

        at org.python.core.__builtin__.__import__(__builtin__.java:1173)

        at org.python.core.imp.importFromAs(imp.java:978)

        at org.python.core.imp.importFrom(imp.java:954)

        at sikuli.Sikuli$py.f$0(C:\Program Files\Sikuli X\sikuli-
script.jar\Lib\sikuli\Sikuli.py:211)

        at sikuli.Sikuli$py.call_function(C:\Program Files\Sikuli X
\sikuli-script.jar\Lib\sikuli\Sikuli.py)

        at org.python.core.PyTableCode.call(PyTableCode.java:165)

        at org.python.core.PyCode.call(PyCode.java:18)

        at org.python.core.imp.createFromCode(imp.java:386)

        at
org.python.core.util.importer.importer_load_module(importer.java:109)

        at
org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161)

        at
org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown
Source)

        at
org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)

        at org.python.core.imp.loadFromLoader(imp.java:513)

        at org.python.core.imp.find_module(imp.java:467)

        at org.python.core.PyModule.impAttr(PyModule.java:100)

        at org.python.core.imp.import_next(imp.java:715)

        at org.python.core.imp.import_name(imp.java:824)

        at org.python.core.imp.importName(imp.java:884)

        at
org.python.core.ImportFunction.__call__(__builtin__.java:1220)

        at org.python.core.PyObject.__call__(PyObject.java:357)

        at org.python.core.__builtin__.__import__(__builtin__.java:1173)

        at org.python.core.imp.importAll(imp.java:998)

        at sikuli$py.f$0(C:\Program Files\Sikuli X\sikuli-
script.jar\Lib\sikuli\__init__.py:3)

        at sikuli$py.call_function(C:\Program Files\Sikuli X\sikuli-
script.jar\Lib\sikuli\__init__.py)

        at org.python.core.PyTableCode.call(PyTableCode.java:165)

        at org.python.core.PyCode.call(PyCode.java:18)

        at org.python.core.imp.createFromCode(imp.java:386)

        at
org.python.core.util.importer.importer_load_module(importer.java:109)

        at
org.python.modules.zipimport.zipimporter.zipimporter_load_module(zipimporter.java:161)

        at
org.python.modules.zipimport.zipimporter$zipimporter_load_module_exposer.__call__(Unknown
Source)

        at
org.python.core.PyBuiltinMethodNarrow.__call__(PyBuiltinMethodNarrow.java:47)

        at org.python.core.imp.loadFromLoader(imp.java:513)

        at org.python.core.imp.find_module(imp.java:467)

        at org.python.core.imp.import_next(imp.java:713)

        at org.python.core.imp.import_name(imp.java:824)

        at org.python.core.imp.importName(imp.java:884)

        at
org.python.core.ImportFunction.__call__(__builtin__.java:1220)

        at org.python.core.PyObject.__call__(PyObject.java:357)

        at org.python.core.__builtin__.__import__(__builtin__.java:1173)

        at org.python.core.imp.importAll(imp.java:998)

        at org.python.pycode._pyx83.f$0(<console>:1)

        at org.python.pycode._pyx83.call_function(<console>)

        at org.python.core.PyTableCode.call(PyTableCode.java:165)

        at org.python.core.PyCode.call(PyCode.java:18)

        at org.python.core.Py.runCode(Py.java:1261)

        at org.python.core.Py.exec(Py.java:1305)

        at
org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)

        at
org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89)

        at
org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70)

        at
org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:46)

        at jython.JeditConsole.pushLine(JeditConsole.java:62)

        at jython.LineCommand.doExecute(JeditConsole.java:195)

        at jython.AbstractCommand.execute(JeditConsole.java:145)

        at jython.JythonExecutor.run(JythonExecutor.java:335)

        at java.lang.Thread.run(Unknown Source)

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: Could not initialize class org.sikuli.script.Finder
------------------------------------------------------------------
To: Rajagopal, Vidya
Subject: Re: [Question #200162]: importing Sikuli in Jython - Jedit IDE

Your question #200162 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/200162

    Status: Open => Answered

RaiMan proposed the following answer:
look in the docs:
http://sikuli.org/docx/faq/040-other-ide.html#how-to-use-sikuli-together-with-other-ide-s

Though this is special for NetBeans and Eclipse, all your questions are
answered somehow and you might get a better insight.

--
If this answers your question, please go to the following page to let us
know that it is solved:
https://answers.launchpad.net/sikuli/+question/200162/+confirm?answer_id=5

If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https://answers.launchpad.net/sikuli/+question/200162

You received this question notification because you asked the question.

________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________

www.accenture.com

--
You received this question notification because you asked the question.

Revision history for this message
RaiMan (raimund-hocke) said :
#10

What about comment #8 ?

Revision history for this message
vidya rajagopal (vidya-rajagopal) said :
#11

When I run the script what you gave I have the following result

>>> import sys
>>> for e in sys.path: print e
...
C:\Program Files\Sikuli X\sikuli-script.jar\Lib\
C:\jython2.5.2\Lib

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of RaiMan
Sent: Tuesday, June 12, 2012 3:46 PM
To: Rajagopal, Vidya
Subject: Re: [Question #200162]: importing Sikuli in Jython - Jedit IDE

Your question #200162 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/200162

    Status: Open => Needs information

RaiMan requested more information:
--- did upadte the path of sikuli script jar file path C:\Program Files\Sikuli X\sikuli-script.jar\Lib\ in Jedit
This contains the Jython stuff and is exactly what might lead to problems (see comment #2).

To overcome this make a script containing:

for e in sys.path: print e

So you can see, what is in sys.path, when your script is running.

Is sikuli-script.jar in Jedit's class path?

--
To answer this request for more information, you can either reply to
this email or enter your reply at the following page:
https://answers.launchpad.net/sikuli/+question/200162

You received this question notification because you asked the question.

________________________________
Subject to local law, communications with Accenture and its affiliates including telephone calls and emails (including content), may be monitored by our systems for the purposes of security and the assessment of internal compliance with Accenture policy.
______________________________________________________________________________________

www.accenture.com

Revision history for this message
RaiMan (raimund-hocke) said :
#12

Ok, this means, that the Jython stuff will be taken from the Sikuli package.
If this is not what you want, you have to change the sequence somehow.

--- java.lang.NoClassDefFoundError: Could not initialize class org.sikuli.script.Finder
the above error might caused by the fact, that Sikuli is not able to locate the OpenCV library stuff, that is in the folder
C:\Program Files\Sikuli X\libs
This folder has to be in the system path at runtime.
Additionally if you need the interactive capture: ...Java\jre6\bin

Revision history for this message
vidya rajagopal (vidya-rajagopal) said :
#13

It works now . Here is details of the step for interfacing Sikuli to Jython in Jedit IDE

1. Install Sikuli for window : Run Sikuli.exe from http://sikuli.org/ in the program file
2. After installation using 7Zip or any unzip format extract the “sikuli-script.jar” file to get “Lib” folder or using Jar utility of Java
3. In the Jedit , go to Plugin and select JythonInterpreter , this will opne the IDe for Jython
4. In the Jython editor go to “Edit Jython Path” and update the path for Sikuli and Jython reference
as C:\Program Files\Sikuli X\Lib\
5. Now in the edtor use the following statement "from sikuli.Sikuli import *"
6. you can check the sucessful import by using the statement ---- input(msg=”Test”)