Jython: ImportError (No module name Test)

Asked by martin jramoy

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:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
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

Revision history for this message
martin jramoy (7incho) said :
#2

Thanks RaiMan, that solved my question.