Using Jython 2.5.2 to run Sikuli scripts from command line

Asked by subhabrata pal

Hi,

I am reasking the question asked in "https://answers.launchpad.net/sikuli/+question/141302" with topic Jython + Sikuli.

I have tried the solution given but no luck:

following is my class path
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Windows Imaging\;C:\Application\apache-ant-1.8.2\bin;C:\Program Files\Java\jdk1.6.0_14\bin;C:\Application\PsTools;C:\Application\PsTools\PsExec;C:\Python27\Lib;C:\Python27\Scripts;C:\Python27\Lib\site-packages;C:\Python27\Lib\site-packages\SeleniumLibrary;C:\Python27\Lib\site-packages\robotide\;C:\Python27\Lib\site-packages\robot\;C:\Python27\Lib\site-packages\wx-2.8-msw-unicode;
C:\jython2.5.2\Lib;C:\jython2.5.2\sikuli-script.jar\Lib;C:\jython2.5.2\Lib\site-packages\SeleniumLibrary;C:\jython2.5.2\Lib\site-packages\robotide;C:\jython2.5.2\Lib\site-packages\robot;C:\jython2.5.2\bin;
################################xxxxxxxxxxxxxx#######################

Following is my code:

from __future__ import with_statement
from sikuli.Sikuli import *

click("Legend.png")

##################################xxxxx###########################
Error:

D:\Sikuli\BarCharts.sikuli>jython BarCharts.py
Traceback (most recent call last):
  File "BarCharts.py", line 2, in <module>
    from sikuli.Sikuli import *
ImportError: No module named sikuli

#############################xxxx##################################
I even tried the unzipping sikuli-script.jar and modifying the script as follows but still no luck

from __future__ import with_statement
import sys
sys.path.append("D:\\sikuli-script\\Lib")
print sys.path
from sikuli.Sikuli import *
click("Legend.png")

##########################xXXXXXXXXXXXXXXXXXXXX######################

Thanks for any help

Question information

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

--1. Sorry to say, but your class path looks very strange
- it looks like a system path, since normally bin directories need not be in a Java class path
- it contains Python27 site-packages entries - this makes no sense with Java
- for Jython and Python: modules living in the directory site-packages are automatically found, no need to have them in any path
- if there are packages, that can be used in both environments (Python and Jython - because they are written completely in Python) they can simply be referenced from the Jython environment using a module-name.pth file, that contains the directory entry of the Python environment

--2. you did not follow the recommendations mentioned in the referenced question
again compact:

- use the environment variables CLASSPATH and JYTHONPATH
- set CLASSPATH=absolute-path-to-sikuli-script.jar (wherever it might be stored, does not matter where)
- set JYTHONPATH=absolute-path-to-Jython\Lib;absolute-path-to-Jython\sikuli-script.jar\Lib
- run the Sikuli script using the jython.bat path-to-script-folder\scriptname.py
- you have to somehow set the image path

there is no need to move sikuli-script.jar elsewhere or even unjar it.

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

Sorry, --2. corrected

--2. you did not follow the recommendations mentioned in the referenced question
again compact:

- use the environment variables CLASSPATH and JYTHONPATH
- set CLASSPATH=absolute-path-to-sikuli-script.jar (wherever it might be stored, does not matter where)
- set JYTHONPATH=absolute-path-to-Jython\Lib;absolute-path-to-sikuli-script.jar\Lib
- run the Sikuli script using the jython.bat path-to-script-folder\scriptname.py
- you have to somehow set the image path

there is no need to move sikuli-script.jar elsewhere or even unjar it.

Revision history for this message
subhabrata pal (subhabratapal12) said :
#3

Yes u r right I made that mistake.

Thanks
Subha