no module named org.sikuli.*

Asked by clem

Hi !

I downloaded the 2016-07-04 SikuliX 1.1.1 version.
I use Ubuntu 14.04.
Jython 2.5.3.
Java 1.7.0_101.

The IDE seems to work well. Nevertheless, when I want to import the sikuli module to a Python (2.7) script with the following lines :

1 import org.sikuli.script.SikulixForJython
2 from sikuli import *

it returns the following error :

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import org.sikuli.script.SikulixForJython
ImportError: No module named org.sikuli.script.SikulixForJython

I commented line 1 to see what happens.
Then it returns me that second error :

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from sikuli import *
  File "~/.Sikulix/Lib/sikuli/__init__.py", line 5, in <module>
    from org.sikuli.basics import Debug
ImportError: No module named org.sikuli.basics

I placed my python script (test.py) in this directory : ~/.Sikulix/Lib/

Has someone any idea to solve this ?
I read the other similar questions I found on launchpad but they did not fit.

Thank you !

Question information

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

--1. never place anything private in the folder ~/.Sikulix ...
... you might loose the content without notice.
The folder is for Sikulix internal use only, unless otherwise stated in special cases.

--2. to run a script with SikuliX's script run feature ...
... the xxx.py file must be in a folder xxx.sikuli

--3. you cannot use Python to run scripts ...
outside the IDE (C-Python). You must use Jython to run the scripts.

How do you try to run your script?

Revision history for this message
clem (cherozene) said :
#2

--1. never place anything private in the folder ~/.Sikulix ...
Alright. It was just to test, because I thought the libraries should be in the same folder as the xxx.py file. My bad.

--2. to run a script with SikuliX's script run feature ...
When the .py file is in a .sikuli folder, it automatically finds the SikuliX libraries ?

--3. you cannot use Python to run scripts ... How do you try to run your script?
Well, pretty sure I am wrong then. I use command line "python test.py" in the folder where my .py file is.

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

--- When the .py file is in a .sikuli folder, it automatically finds the SikuliX libraries ?
When you use the sikulix.jar/runsikulix to run scripts from the IDE or from commandline, then internally it is arranged, that the libraries are on sys.path.
SikuliX version 1.1.x will only run scripts that are arranged as xxx.py and possible images in a aaa.sikuli folder.
Version 2 will have more options.

Revision history for this message
clem (cherozene) said :
#4

Okay. It raises two new questions then.

1-- According to the following web page, it is possible to run SikuliX Scripts without opening the IDE (with the option --run or -r) and this is what I would like to do : to use SikuliX without the IDE.
http://sikulix-2014.readthedocs.io/en/latest/faq/010-command-line.html#how-to-run-sikulix-from-command-line

I am in the folder where "runsikulix" file is.
I type this command : runsikulix --run <path-to-my-.sikuli-folder>/first_tests.sikuli

This returns me "runsikulix: command not found"

If I type <path-to-sikuli)/runsikulix --run <path-to-my-.sikuli-folder>/first_tests.sikuli
It opens the IDE. Not even my script.

2-- (not sure that it is possible before version 2) How to create a file "MyRobotFrameworkLibrary.py" which uses the SikuliX module, to be included in RobotFramework with the setting "Library MyRobotFrameworkLibrary.py" ?
May I write :
import org.sikuli.script.SikulixForJython
from sikuli import *
at the beginning of my lib ? (pretty sure I cannot, but I prefer asking)

Thanks RaiMan !

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

Uuups, apparently --run is not understood.

You seem to be on Mac:

- being in folder having runsikulix:
./runsikulix -r <path-to>/yourscript.sikuli

- being in the folder that contains the script folder:
<path-to>/runsikulix -r yourscript.sikuli

About RFW support carefully read:
http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework

Revision history for this message
clem (cherozene) said :
#6

Hi again !

I am not on Mac but on Linux Ubuntu 14.04.

Indeed these two commands work. It was probably the --run that is not understood, you right.
I am curious, what if I have 2 python files in my .sikuli file ?
I read this http://sikulix-2014.readthedocs.io/en/latest/faq/010-command-line.html#how-to-run-sikulix-from-command-line
If I well understand, we can have multi .sikuli files. What about multi .py files ?
Does SikuliX only consider the .py named like the .sikuli ?

-- About RFW support carefully read....
I read it but I am not sure to absolutely understand it. I will try to do what I want and maybe come back later with new questions if necessary.

Thanks for support, problem solved :-)

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

-- I am curious, what if I have 2 python files in my .sikuli file ?
only the one named like the containing folder can be run, but other contained .py files may of course be imported.