ImportError in "from org.sikuli.basics import Debug", no module named sikuli

Asked by Erich Fiederer

As a precursor, I'm a total jython newbie. I've set up a series of sikuli scripts to run through all the basics of my software, and now I'm trying to create a unittest framework with python/jython.

I am using sikuli 1.1 on OSX. When I try to run the test file, "mytest.py", I get an error that I can't figure out how to fix:

Erichs-MacBook-Pro:Sikuli-1.1 erich$ jython mytest.py
Traceback (most recent call last):
  File "mytest.py", line 6, in <module>
    from sikuli.Sikuli import *
  File "/Users/erich/Library/Application Support/Sikulix/Lib/sikuli/sikuli.py", line 6, in <module>
    from org.sikuli.basics import Debug
ImportError: No module named sikuli

Here is the beginning of the "mytest.py" file:

import sys
myScriptPath = "/Users/erich/Desktop/Sikuli-1.1"
sikuliPath = "/Users/erich/Library/Application Support/Sikulix/Lib/sikuli"
if not myScriptPath in sys.path: sys.path.append(myScriptPath)
if not sikuliPath in sys.path: sys.path.append(sikuliPath)
from sikuli.Sikuli import *
import unittest
import Batchview_basic

Question information

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

with the latest 1.1.0 you only need this:

if you run from IDE or from command line:

import unittest
import Batchview_basic

if all .sikuli are in the same folder (which is recommended for beginners.

Revision history for this message
Erich Fiederer (erichfiederer) said :
#2

Hi RaiMan,

Thanks for the response. I've done what you said, but now i'm getting the following:

ImportError: No module named Batchview_basic

I have a theory, could this be because I made my .sikuli files in 1.0? Do I have to recreate my .sikuli files in 1.1 for it to work properly?

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

-- if all .sikuli are in the same folder (which is recommended for beginners.
this is the point.
I supposed, that Batchview_basic is some .sikuli folder (hence a Sikuli script).

you get rid of the error if you take care, that your main script (the one you are running) and Batchview_basic.sikuli are in the same folder.

otherwise you have to add something like
myScriptPath = "/Users/erich/Desktop/Sikuli-1.1"
if not myScriptPath in sys.path: sys.path.append(myScriptPath)

supposing that "/Users/erich/Desktop/Sikuli-1.1" is the folder containing Batchview_basic.sikuli

Revision history for this message
Erich Fiederer (erichfiederer) said :
#4

The problem I am having is that they are all in the same folder, but I am still having the same error.

All of my .sikuli folders are in one directory along with myTest.py.

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

ok, what is myTest.py ?

put it in a folder myTest.sikuli in your "same folder" and run this.

Revision history for this message
Erich Fiederer (erichfiederer) said :
#6

Ah, thank you RaiMan! I was trying to write my test script as a python file rather than using the IDE and saving as a .sikuli. All fixed!