Layout manager is provided by the application main window. If you don’t have a main window then you don’t have a layout manager. You can fix the error by removing --no-main-window.
Thank you for providing the script. I successfully ran the segmentation process. Is it possible to generate 3D view images using a batch CLI command with screencapture? I understand that screencapture requires the layout manager to generate images, which typically needs the main window. Since this is not feasible with batch CLI commands running in a Unix terminal, is there an alternative workaround for this?
You can do everything with commands on the terminal. You can pass Python commands as command-line arguments or you can put all the commands in a .py file and execute that from the command-line. If popping up of a GUI window is bothering you then you can use a dockerized version of Slicer.