How to run sikuli script in Eclipse

Asked by Prateek Sahu

i have configured eclipse for jython ...

Now I want to run my sikuli script which I have created using sikuli ide.

Please help me how can I run my .sikuli file using Eclipse...

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Calle Rundgren (c-rundgren) said :
#1

Have you tested using this tutorial? http://sikuli.org/docx/faq/040-other-ide.html

Revision history for this message
Prateek Sahu (prateek-sahu01apr) said :
#2

Yes I have read this tutorial...
and I have followed the mentiond steps..

Now i want to run my sikuli script using eclipse...please help me...I have already configured jython 2.2.1

Please help me....

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

You cannot run the .sikuli in eclipse.

You have to use the contained .py and you have to take care for the images by e.g. setBundlePath() or by using the image path feature.

Revision history for this message
Prateek Sahu (prateek-sahu01apr) said :
#4

Thank You

It would be great if could please tell me step wise procedure how I can use .py file in Eclipse...

I am using Eclipse 3.4 and Jython 2.2.1

Revision history for this message
Prateek Sahu (prateek-sahu01apr) said :
#5

doubleClick("1321868315871.png")
wait("gelCSopraInd.png",5)
click(Pattern("IFnFll1.png").similar(0.79).targetOffset(2,0))
click("TELEXT.png")
click(Pattern("1321870005917.png").similar(0.97))
type(Pattern("1321868884870.png").similar(0.95),"Prateek Sahu")
click(Pattern("1321870733463.png").similar(0.93))
click("Search.png")

This is the .py script i have got using Sikuli IDE...
Now how I have to use this in Eclipse.

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

-- in Eclipse make a new PyDev project
- name it
- uncheck 'Project contents' use defaults
- browse for the directory .sikuli, that you want and confirm
- select Jython as Project type
- uncheck 'create default .....'
- press finish.

-- select in menu Run: Run configurations ...
- right click on JythonRun and select new
- in Project select your project and
- in Main Module select the .py file
- at top give it a name (e.g. same as project name)
- press Close

There are different possibilities to run it now - I leave it to you to find out ;-)

BTW:
in your script, when run from Eclipse/Jython, you need the statement "from sikuli import *", as mentioned in the docs, you stated, that you have read them.

Revision history for this message
Prateek Sahu (prateek-sahu01apr) said :
#7

Thanks RaiMan..
I had already follwed steps you mentioned in your last answer...

now when I am running the follwing script and an error is coming

import sys
print "before Sikuli"
for e in sys.path: print e
from sikuli.Sikuli import *
print "after Sikuli"
for e in sys.path: print e

before Sikuli
D:\projects\prj-parameters\Coding\workspace1\eBA
C:\jython2.2.1\Lib
D:\projects\prj-parameters\Coding\workspace1\eBA
C:\sikuli-script\Lib
C:\Program Files\Sikuli X\sikuli-script.jar
D:\projects\prj-parameters\Coding\eclipseconf\dropins\PyDev 2.2.4\plugins\org.python.pydev_2.2.4.2011110216\PySrc
C:\jython2.2.1
D:\tools\com\sun\java\jdk\1.5.0_16\jre\lib\rt.jar
D:\tools\com\sun\java\jdk\1.5.0_16\jre\lib\jsse.jar
D:\tools\com\sun\java\jdk\1.5.0_16\jre\lib\jce.jar
D:\tools\com\sun\java\jdk\1.5.0_16\jre\lib\charsets.jar
D:\tools\com\sun\java\jdk\1.5.0_16\jre\lib\ext\dnsns.jar
D:\tools\com\sun\java\jdk\1.5.0_16\jre\lib\ext\localedata.jar
D:\tools\com\sun\java\jdk\1.5.0_16\jre\lib\ext\sunjce_provider.jar
D:\tools\com\sun\java\jdk\1.5.0_16\jre\lib\ext\sunpkcs11.jar
__classpath__
Traceback (innermost last):
  File "D:\projects\prj-parameters\Coding\workspace1\eBA\s1.py", line 4, in ?
  File "C:\sikuli-script\Lib\sikuli\__init__.py", line 3, in ?
  File "C:\sikuli-script\Lib\sikuli\Sikuli.py", line 7
SyntaxError: future feature with_statement is

Please help....

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

You have to use at least Jython 2.5.1 to run Sikuli features.

So again I recommend to use Jython 2.5.2. If you have problems with the install, just unzip the download and configure the Jython interpreter in Eclipse by browsing to the contained jython.jar. For the use with Eclipse there is no need to install Jython on your machine, only access to the jython.jar is needed.

Revision history for this message
Prateek Sahu (prateek-sahu01apr) said :
#9

Ok RaiMan

I have tried to download jython 2.5.2 from www.jython.org many times but the downloaded file is corrupt.

If you have jython 2.5.2 please share, it would be really great.

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

Really strange. I never had any problem on any of my systems.

Anyway, send me an e-mail to https://launchpad.net/~raimund-hocke, I will send you the stuff (the jython.jar is about 9 MB).

Revision history for this message
Prateek Sahu (prateek-sahu01apr) said :
#11

Thanks RaiMan for sharing jython.jar. It really worked

now I am trying to run a sikuli script

import unittest
from sikuli.Sikuli import * //Warning

class Test(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

.................................and so on

When I am running this a warning message is shown the warning message is as follows:

unused in wild inport:button.FOREVER,ImageLocato,JScreen,KEY_CTRL,KEY_SHIFT,Key,Sikuli:EventAdapter,SikuliScript,
capture.getImagePach,java.io,selectRegion,setShowActions,switchApp,time....othersuppresed

what should I do...??

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

This is an Eclipse IDE warning, that reminds you, that you might have imported too much stuff using import *.
Just ignore it in this case.

Revision history for this message
Prateek Sahu (prateek-sahu01apr) said :
#13

Thanks RaiMan, that solved my question.

Revision history for this message
Nidere (nidere) said :
#14

Hey there, RaiMan!

I followed all the steps above and in the http://doc.sikuli.org/faq/040-other-ide.html
However, my Eclipse is giving me an error when I try to run any script:

Traceback (most recent call last):
  File "C:\Users\user-c277\workspace\Sikuli\Dakota.py", line 1, in <module>
    from sikuli.Sikuli import *
  File "__pyclasspath__/sikuli$py.class", line 33, in <module>
  File "C:\Users\user-c277\Downloads\sikuli\Screen.py", line 11, in <module>
    import Sikuli
  File "C:\Users\user-c277\Downloads\sikuli\Sikuli.py", line 545, in <module>
    use()
  File "C:\Users\user-c277\Downloads\sikuli\Sikuli.py", line 378, in use
    SCREEN = Screen()
NameError: global name 'Screen' is not defined

What did I do wrong?

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