# ModuleNotFoundError when importing from slicer.parameterNodeWrapper

**URL:** https://discourse.slicer.org/t/modulenotfounderror-when-importing-from-slicer-parameternodewrapper/29656
**Category:** Support
**Created:** [May 25, 2023, 9:16pm UTC](https://discourse.slicer.org/t/modulenotfounderror-when-importing-from-slicer-parameternodewrapper/29656 "2023-05-25T21:16:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![asyeda](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@asyeda](https://discourse.slicer.org/u/asyeda)
#### Post date: [May 25, 2023, 9:16pm UTC](https://discourse.slicer.org/t/modulenotfounderror-when-importing-from-slicer-parameternodewrapper/29656/1 "2023-05-25T21:16:27Z")

</div>

I am developing a scripted module in Slicer 5.2.2 and one key issue is that when I save/load the scene I want to preserve the class attributes in addition to the views and segmentations so I can fully restore the UI to its previous state. As suggested by this thread:

> [@How to save slicer scene with both slicer data and with "self.variables" within custom widget](https://discourse.slicer.org/t/how-to-save-slicer-scene-with-both-slicer-data-and-with-self-variables-within-custom-widget/9830/2):
>
> You raise a very important point. It is easy to write a scripted module that “works” and it is very tempting to stop there - and not spend time with implementing automatic tests, saving of module state to the scene, etc. Developers are supposed to save all information that is necessary to recreate the current state of the module in nodes in the MRML scene. You can find some useful general information about this in the first part of [PerkLab Scripted Module Development tutorial](https://www.slicer.org/wiki/Documentation/Nightly/Training#PerkLab.27s_Slicer_bootcamp_training_materials). This practice is …

I have modified my widget class similar to the `VectorToScalarVolume` class. However, the main issue is that I get a `ModuleNotFound` error on starting up Slicer.

The error is coming from the line:

`from slicer.parameterNodeWrapper import parameterNodeWrapper`

The full traceback looks like this:

```auto
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/imp.py", line 169, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 613, in _exec
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/{myname}/Desktop/{modulename} project/Code/{modulename}-main/{modulename}/{modulename}.py", line 32, in <module>
    from slicer.parameterNodeWrapper import parameterNodeWrapper
ModuleNotFoundError: No module named 'slicer.parameterNodeWrapper'
[Qt] loadSourceAsModule - Failed to load file "/Users/{myname}/Desktop/{modulename} project/Code/{modulename}-main/{modulename}/{modulename}.py" as module "{modulename}" !
[Qt] Fail to instantiate module {modulename}
[Qt] The following modules failed to be instantiated:
[Qt] {modulename}

```

It’s a confusing error, since this line seems to work just fine in [VectorToScalarVolume](https://github.com/Slicer/Slicer/blob/main/Modules/Scripted/VectorToScalarVolume/VectorToScalarVolume.py) and the [official documentation](https://slicer.readthedocs.io/en/latest/developer_guide/parameter_nodes/overview.html). I’m working with Slicer 5.2.2 and haven’t had issues importing from `slicer.util` or elsewhere. I also checked the [changelog for v5.2](https://discourse.slicer.org/t/slicer-5-2-summary-highlights-and-changelog/26916/2) but no luck.

What could be causing this issue?

---

<div class="post-metadata">

### Author: ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)
#### Post date: [May 25, 2023, 9:26pm UTC](https://discourse.slicer.org/t/modulenotfounderror-when-importing-from-slicer-parameternodewrapper/29656/2 "2023-05-25T21:26:30Z")

</div>

> [@asyeda](#):
>
> I am developing a scripted module in Slicer 5.2.2

`slicer.parameterNodeWrapper` is not available in Slicer 5.2.2. It is currently only available in latest Slicer Preview. That is why it is not working for you when using Slicer 5.2.2.

VectorToScalarVolume code for Slicer 5.2.2

> <https://github.com/Slicer/Slicer/blob/v5.2.2/Modules/Scripted/VectorToScalarVolume/VectorToScalarVolume.py>

versus VectorToScalarVolume code for latest Slicer Preview (aka `main` branch)

> <https://github.com/Slicer/Slicer/blob/main/Modules/Scripted/VectorToScalarVolume/VectorToScalarVolume.py>

---

<div class="post-metadata">

### Author: ![asyeda](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@asyeda](https://discourse.slicer.org/u/asyeda)
#### Post date: [May 25, 2023, 9:32pm UTC](https://discourse.slicer.org/t/modulenotfounderror-when-importing-from-slicer-parameternodewrapper/29656/3 "2023-05-25T21:32:19Z")

</div>

I see - does `VectorToScalarVolume` in 5.2 implement this functionality too? (saving class attributes when saving mrml scene)
