# Reload module error

**URL:** <https://discourse.slicer.org/t/reload-module-error/39581>\
**Category:** Support\
**Tags:** extensions-manager, python, loadable-module\
**Created:** [October 8, 2024, 9:16am UTC](https://discourse.slicer.org/t/reload-module-error/39581 "2024-10-08T09:16:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shirly\_Someck](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shirly_someck/32/77978_2.png) [@Shirly\_Someck](https://discourse.slicer.org/u/Shirly_Someck)\
**Post date:** [October 8, 2024, 9:16am UTC](https://discourse.slicer.org/t/reload-module-error/39581/1 "2024-10-08T09:16:37Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 8, 2024, 11:16am UTC](https://discourse.slicer.org/t/reload-module-error/39581/2 "2024-10-08T11:16:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Shirly\_Someck](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shirly_someck/32/77978_2.png) [@Shirly\_Someck](https://discourse.slicer.org/u/Shirly_Someck)\
**Post date:** [October 9, 2024, 4:55pm UTC](https://discourse.slicer.org/t/reload-module-error/39581/3 "2024-10-09T16:55:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 10, 2024, 4:17am UTC](https://discourse.slicer.org/t/reload-module-error/39581/4 "2024-10-10T04:17:04Z")

</div>

> 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)?

---

<div class="post-metadata">

**Author:** ![Shirly\_Someck](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/shirly_someck/32/77978_2.png) [@Shirly\_Someck](https://discourse.slicer.org/u/Shirly_Someck)\
**Post date:** [October 10, 2024, 8:59am UTC](https://discourse.slicer.org/t/reload-module-error/39581/5 "2024-10-10T08:59:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 10, 2024, 11:44am UTC](https://discourse.slicer.org/t/reload-module-error/39581/6 "2024-10-10T11:44:27Z")

</div>

Start with the template generated by the Extension Wizard module, confirm that it reloads, and then adapt it with your code.
