I’ve been using slicer a few months now, and recently trying to write an extension.
Yesterday I moved some of my python files to a new path (since I had trouble importing them to my project), and since then I can’t “reload” my extension.
This is the error I get:
Traceback (most recent call last):
File “C:\d\Slicer 5.6.2\bin\Python\slicer\ScriptedLoadableModule.py”, line 246, in onReload
slicer.util.reloadScriptedModule(self.moduleName)
File “C:\d\Slicer 5.6.2\bin\Python\slicer\util.py”, line 1420, in reloadScriptedModule
widget.parent.reload()
UnboundLocalError: local variable ‘widget’ referenced before assignment
C:\d\Slicer 5.6.2\bin\Python\slicer\util.py:2786: UserWarning: does not have observer
warn(“does not have observer”)
I’m not sure if it’s related or not, but the python debugger extension is also throwing this error: AttributeError: module ‘modules’ has no attribute ‘PyDevRemoteDebugInstance’.
I’ve tried to reinstall 3D Slicer, but it has not solved the problem.
The path I use for my extension is C:\d\ProbeView
I would appreciate any help!
Thanks in advance,
Shirly
The error does not contain anything related to your module. Are you sure this is the complete error message? What happens if you remove the module path from Additional module directories?
Normally moving a scripted module from one folder to another should be OK if you change the path in Settings.
I know, this is very weird, since it seems like it is not related to my module at all, but to some problem in accessing functions to operate slicer… yes this is the complete error message.
File “C:\d\Slicer 5.6.2\bin\Python\slicer\util.py”, line 1420, in reloadScriptedModule
widget.parent.reload()
UnboundLocalError: local variable ‘widget’ referenced before assignment
This error is logged when the module widget is not found. Does your module have a widget? Does the Python file’s name, the module class name, module widget class name all match (MyModule.py, MyModule, MyModuleWidget)?
My module has a widget, and the python file’s name, the class name and the widget class name all match. Slicer has no problem initiating the module, it appears fine when I start Slicer, it just won’t “reload” it.