# Cannot import name 'vtkMRMLPathPlannerTrajectoryNode' at launch

**URL:** <https://discourse.slicer.org/t/cannot-import-name-vtkmrmlpathplannertrajectorynode-at-launch/44227>\
**Category:** Support\
**Tags:** python, slicerigt, scripted\
**Created:** [August 28, 2025, 1:29am UTC](https://discourse.slicer.org/t/cannot-import-name-vtkmrmlpathplannertrajectorynode-at-launch/44227 "2025-08-28T01:29:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruffsl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ruffsl/32/80858_2.png) [@ruffsl](https://discourse.slicer.org/u/ruffsl)\
**Post date:** [August 28, 2025, 1:29am UTC](https://discourse.slicer.org/t/cannot-import-name-vtkmrmlpathplannertrajectorynode-at-launch/44227/1 "2025-08-28T01:29:55Z")

</div>

I have a working scripted extension that enables a user to select a path within any chosen trajectory list, as generated via the separate PathExplorer widget from the SlicerIGT extension:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/a/ead1f4331c75e1ab7319118d74978abb8e00fe1d.png)

- [SlicerIGT/PathExplorer at master · SlicerIGT/SlicerIGT · GitHub](https://github.com/SlicerIGT/SlicerIGT/tree/master/PathExplorer)

However, after passing tests and restarting Slicer, I noticed a new `ImportError` during launch:

```auto
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/slicer/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 "/opt/air_ws/src/slicer/AirIGT/AirGUI/AirGUI.py", line 19, in <module>
    from slicer import (
ImportError: cannot import name 'vtkMRMLPathPlannerTrajectoryNode' from 'slicer' (/opt/slicer/bin/Python/slicer/ __init__.py)
[Qt] loadSourceAsModule - Failed to load file "/opt/air_ws/src/air-sandbox/src/slicer/AirIGT/AirGUI/AirGUI.py" as module "AirGUI" !
[Qt] Fail to instantiate module "AirGUI"
[Qt] The following modules failed to be instantiated:
[Qt] AirGUI

```

I import `vtkMRMLPathPlannerTrajectoryNode` from PathExplorer for Parameter node typing:

```python
from slicer import (
    vtkMRMLMarkupsLineNode,
    vtkMRMLNode,
    vtkMRMLPathPlannerTrajectoryNode,
    vtkMRMLScalarVolumeNode,
)

```

```python
@parameterNodeWrapper
class AirGUIParameterNode:
    inputPaths: vtkMRMLPathPlannerTrajectoryNode

```

Providing convent integration with nodeTypes & SlicerParameterName for the pathsSelector UI:

```xml
       <widget class="qMRMLNodeComboBox" name="pathsSelector">
        <property name="toolTip">
         <string>Pick input paths.</string>
        </property>
        <property name="nodeTypes">
         <stringlist notr="true">
          <string>vtkMRMLPathPlannerTrajectoryNode</string>
         </stringlist>
        </property>
        <property name="addEnabled">
         <bool>false</bool>
        </property>
        <property name="removeEnabled">
         <bool>false</bool>
        </property>
        <property name="SlicerParameterName" stdset="0">
         <string>inputPaths</string>
        </property>
       </widget>

```

- [SlicerIGT/PathExplorer/Resources/UI/qSlicerPathExplorerModuleWidget.ui at cc9678a9b6f91aa9ffde3ff0176cad357335616f · SlicerIGT/SlicerIGT · GitHub](https://github.com/SlicerIGT/SlicerIGT/blob/cc9678a9b6f91aa9ffde3ff0176cad357335616f/PathExplorer/Resources/UI/qSlicerPathExplorerModuleWidget.ui#L33)

Perhaps this results from some race conditions or lazily loaded imports? I did try declaring my external extension dependencies and moving/delaying the offending imports to inside my `AirGUIParameterNode` class as a work around for this limitation, but no dice. 🎲

```python
class AirGUI(ScriptedLoadableModule):
    def __init__ (self, parent):
        ScriptedLoadableModule. __init__ (self, parent)
        self.parent.title = _("Air GUI")
        self.parent.categories = [translate("qSlicerAbstractCoreModule", "Wizards")]
        self.parent.dependencies = [
            "OpenIGTLinkIF",
            "PathExplorer",
        ]

```

Any recommendation for scripted modules using `vtkMRML` types from external C++ extentions?  
Thanks!

---

<div class="post-metadata">

**Author:** ![ruffsl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ruffsl/32/80858_2.png) [@ruffsl](https://discourse.slicer.org/u/ruffsl)\
**Post date:** [October 9, 2025, 2:17am UTC](https://discourse.slicer.org/t/cannot-import-name-vtkmrmlpathplannertrajectorynode-at-launch/44227/2 "2025-10-09T02:17:43Z")

</div>

@lassoan , any suggested workarounds? Perhaps some kind of manual typecasting?
