Jython: ImportError (No module name Test)

Asked by martin jramoy on 2018-10-09

When importing a class Test.py from Sikuli i'm getting the following error:

[error] script [ Sikuli1 ] stopped with error in line 5
[error] ImportError ( No module named Test )

-----------------------------------------------------------------------------
import sys
from os.path import dirname
sys.path.append(dirname(dirname(sys.argv[0])))
from Test import *

with Test() as testing:
    wait (6)
    print"Sikuli1"

-----------------------------------------------------------------------------

This is the Class file:

from sikuli import *
import sys

from os.path import isdir, dirname

class Test:
    def __enter__(self):
    def captura(self):
        print "Test"

thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2018-10-11
Last query:
2018-10-11
Last reply:
2018-10-09
Best RaiMan (raimund-hocke) said : #1

the usage of sys.argv[0] is not consistently compatible with the Python conventions (in most cases only contains the bare name of the script).

With SikuliX you should use the features:
https://sikulix-2014.readthedocs.io/en/latest/scripting.html#file-and-path-handling-convenience-functions

martin jramoy (7incho) said : #2

Thanks RaiMan, that solved my question.