from sikuli import *. ImportError: No moude named sikuli

Asked by kevinfree

I am running Sikuli X 1.1.0 on Win7 Professional x64. Jython 2.7.0
I have built several test scripts which run fine in the Sikuli IDE, but do not run correctly from the command line.

Here is my code:
===========================================================================
import unittest
from sikuli import *

class TestType(unittest.TestCase):
    def testOpenText(self):
        try:
            doubleClick("C:/Sikulix1.1.1/TestKeyIn.sikuli/1487128963180.png")
            wait("C:/Sikulix1.1.1/TestKeyIn.sikuli/1487129022614.png")
        except:
            print "StartFailed"
        if exists("C:/Sikulix1.1.1/TestKeyIn.sikuli/1487129022614.png"):
            type("123456")
            sleep(1)
            type(Key.ENTER)
            sleep(1)
            type("KEVIN")
            print "OpenText_Succeeded"
            assert True
        else:
             print "OpenText_Failed"
             assert False
    def testSaveText(self):
        try:
            sleep(1)
            click("C:/Sikulix1.1.1/TestKeyIn.sikuli/1487129113840.png")
            sleep(1)
            click("C:/Sikulix1.1.1/TestKeyIn.sikuli/1487129165925.png")
            print "SaveText_Succeeded"
            assert True
        except:
            print "SaveText_Failed"
            assert False

suite = unittest.TestLoader().loadTestsFromTestCase(TestType)
unittest.TextTestRunner().run(suite)
===========================================================================

It can runs at Sikuli IDE.

But if I use windows command line:
jython test.py

I got the error msg:
Traceback <most recent call last>:
  File "test.py", line 2, in <module>
    from sikuli import *
ImportError: No module named sikuli

Could someone help me please ?
Thanks.

Question information

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

Sorry, I still don't get it.

I added:
import org.sikuli.script.SikulixForJython
in my script at the beginning

And I got the error msg:
Traceback <most recent call last>:
  File "test.py", line 1, in <module>
    import org.sikuli.script.SikulixForJython
ImportError: No module named sikuli

Revision history for this message
kevinfree (kevinfree) said :
#3

I put the sikulixapi.jar into the C:\Program Files (x86)\Java\jdk1.8.0_111\lib
And then I run the command line :
jython test.py
It works.

But I want to make a test result.xml.
I run command line:
jython C:\jython2.7.0\bin\py.test-jython --junitxml result.xml

I got the error msg:
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create
PyString with non-byte value

Revision history for this message
TestMechanic (ndinev) said :
#4

How you are running your script ?

http://sikulix-2014.readthedocs.io/en/latest/faq/010-command-line.html

it should be

runsikulix.cmd -r <path_to_directory.sikuli>

Can you help with this problem?

Provide an answer of your own, or ask kevinfree for more information if necessary.

To post a message you must log in.