简体   繁体   中英

Can't import sikuli modules from Sikuli IDE 1.0.0

I'm using Sikuli IDE 1.0.0 on Mac, trying to get a simple test case working where I call a script in one module from another. The modules are all in the same directory.

testModule.sikuli just has this:

from sikuli import *

def testFunc():
    exit(1)

testImport.sikuli just has this:

import testModule
reload(testModule)
testModule.testFunc()

running testImport just yields: [error] ImportError ( No module named testModule ) on the import testModule line.

I've tried various additions to testImport including:

myScriptPath="[my project path]"
if not myScriptPath in sys.path: sys.path.append(myScriptPath)

None of these seem to work.

I think the import just brings the new functions into the same module.

Try calling testFunc() instead of testModule.testFunc() .

I've encountered the same issue. I have solved this problem using classes.

Try this code:

testModule.sikuli:

from sikuli import *
class test:
    def testFunc(self):
        exit(1)

testImport.sikuli:

import testModule
foo = testModule.test()
foo.testFunc()

This should work assuming your files are in the same folder (for example ./test/testImport.sikuli and ./test/testModule.sikuli)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM