Does reload(module) is bugged in 2.0.6 java17 on Win11?

Asked by Adrian

H all,

I'v updated Sikuli from 1.0.1 to 2.0.6 (sikulixidewin-2.0.6-20211110.175831-5.jar) Java 17 on Windows 11 and still have problem with reloading module (sub script). Im asking because do not remember this problem in 1.0.1 and its annoying to reload full ide.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: reload() argument must be a module
[error] IDE: Run Script: internal error:

I lurked alot on sikuli sites and python reload module sites but nothing worked

Main:
#had this
import sub
reload(sub)
from sub import *
#have only this one below now, coz figured out that this works the same as above one and give the same error. Sub script is working on both
from sub import *

Sub:
from sikuli import *
use() #need to be here in Win11, found here on forum - Thank You RaiMan for that workaround :)

but tried dozens diffrent ways from python and sikuli sites like...

import imp
imp.reload(sub)
from sub import *

or

import sys # i know dont have to coz red that its imported by default
import importlib
importlib.reload(sys)

and many more... spent a lot of time on that withous succeed. Somebody tried 2.0.6 on java17 and Windows 11 setup?

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

1. reload(sub) is only needed, if you change its content while running the main again in the IDE

2. the correct usage would be:
import sub
reload(sub)
from sub import * # only needed if you want to use the names in sub without sub.name

3. in 2.0.x reload is no longer needed for valid .sikuli Scripts that are found on sys.path

so:
#main.sikuli
from sub import *
action()

#sub.sikuli
from sikuli import *
def action():
    popup("hello from sub")

should work (both .sikuli in same folder)

test it by changing the popup text in sub and run main again

Can you help with this problem?

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

To post a message you must log in.