How can I run a python script on slicer?

Operating system: Windows 11 pro
Slicer version: 5.0.3

Hi,
I’m trying to run a simple python scripts that loads a patient on Slicer.
If I run the code line by line in the python interactor all goes as espected.
Instead, if I try to run a script that contains the same lines of code using C:\Users\Marco\Slicer-5.0.3\Slicer.exe --python-script “C:\Users\Marco\Desktop\tirocinio\scripting_3DSlicer\Dice_Hausdorff.py” nothing happens.
What am I doing wrong?
Thank you for the support.

You could run

exec(open(r"C:\Users\Marco\Desktop\tirocinio\scripting_3DSlicer\Dice_Hausdorff.py").read())

from the Python Interactor.

1 Like