简体   繁体   English

无法从Sikuli IDE 1.0.0导入sikuli模块

[英]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. 我在Mac上使用Sikuli IDE 1.0.0,试图获得一个简单的测试用例,在另一个模块的一个模块中调用脚本。 The modules are all in the same directory. 这些模块都在同一目录中。

testModule.sikuli just has this: testModule.sikuli只是这样:

from sikuli import *

def testFunc():
    exit(1)

testImport.sikuli just has this: testImport.sikuli只是这样:

import testModule
reload(testModule)
testModule.testFunc()

running testImport just yields: [error] ImportError ( No module named testModule ) on the import testModule line. 在导入testModule行上,运行testImport只会产生: [error] ImportError ( No module named testModule )

I've tried various additions to testImport including: 我已经尝试过对testImport进行各种添加,包括:

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() . 尝试调用testFunc()而不是testModule.testFunc()

I've encountered the same issue. 我遇到了同样的问题。 I have solved this problem using classes. 我已经使用类解决了这个问题。

Try this code: 试试这个代码:

testModule.sikuli: testModule.sikuli:

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

testImport.sikuli: 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) 假设您的文件位于同一文件夹中,则此方法应该有效(例如./test/testImport.sikuli和./test/testModule.sikuli)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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