Way to acess eagag

Hello, I need a way to access the segmentation node, as I need to save the segmentations.

However, I am using pythonSlicer to run the application and I cannot use MRML according to the documentation at slicer — 3D Slicer documentation.

Here is the code:

segmentation_nodes = slicer.mrmlScene.GetNodesByClass("vtkMRMLSegmentationNode")
 

# I am receiving the following error when I call the function to save a segmentation:
{
  "error": "Failed to process the segmentations: module 'slicer' has no attribute 'mrmlScene'"
}

I am looking for a way to do this without using mrml. Thank you in advance!

https://slicer.readthedocs.io/en/latest/developer_guide/slicer.html#module-slicer:~:text=Warning-,These%20attributes%20are%20only%20set%20in%20the%20Python%20environment%20embedded%20in%20the%20Slicer%20main%20application.,-Additionally%20for%20all