# slicer.util.MRMLNodeNotFoundException: could not find nodes in the scene by name or id '' error

**URL:** <https://discourse.slicer.org/t/slicer-util-mrmlnodenotfoundexception-could-not-find-nodes-in-the-scene-by-name-or-id-error/14135>\
**Category:** Support\
**Created:** [October 19, 2020, 12:44pm UTC](https://discourse.slicer.org/t/slicer-util-mrmlnodenotfoundexception-could-not-find-nodes-in-the-scene-by-name-or-id-error/14135 "2020-10-19T12:44:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)\
**Post date:** [October 19, 2020, 12:44pm UTC](https://discourse.slicer.org/t/slicer-util-mrmlnodenotfoundexception-could-not-find-nodes-in-the-scene-by-name-or-id-error/14135/1 "2020-10-19T12:44:34Z")

</div>

Operating system: windows 10  
Slicer version: 4.11.20200930  
Expected behavior: run a scripted python module without errors

Hello. I’m using a scripted python module on 3D slicer version 4.4 and it works as it should.  
However, when I use the same module in the 3D slicer version 4.11.20200930 it has different behavior and I’m getting this error message:

slicer.util.MRMLNodeNotFoundException: could not find nodes in the scene by name or id ‘’.  
Are there any changes in getting the imported data?

I would really appreciate your help.

Thanks,  
Mariana

---

<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 19, 2020, 12:56pm UTC](https://discourse.slicer.org/t/slicer-util-mrmlnodenotfoundexception-could-not-find-nodes-in-the-scene-by-name-or-id-error/14135/2 "2020-10-19T12:56:50Z")

</div>

`getNode` is a helper function that used to return `None` when there were no matches, but in more recent Slicer it raises that exception to be explicit. Now you need to add a catch it, [something like this](https://github.com/Slicer/Slicer/blob/47deb76d7556e40de4e25e585c4b24a63a153da5/Base/Python/sitkUtils.py#L225-L232).

---

<div class="post-metadata">

**Author:** ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)\
**Post date:** [October 19, 2020, 1:53pm UTC](https://discourse.slicer.org/t/slicer-util-mrmlnodenotfoundexception-could-not-find-nodes-in-the-scene-by-name-or-id-error/14135/3 "2020-10-19T13:53:01Z")

</div>

Thank you very much. It works!

---

<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 19, 2020, 1:55pm UTC](https://discourse.slicer.org/t/slicer-util-mrmlnodenotfoundexception-could-not-find-nodes-in-the-scene-by-name-or-id-error/14135/4 "2020-10-19T13:55:33Z")

</div>

You can also use `slicer.mrmlScene.GetNodeByID()` as a drop-in replacement (if node is not found then it returns `None` instead of throwing an exception). Key differences between the two methods are described [here](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_node_object_from_the_scene_from_node_name_or_ID).
