# How can I run a python script on slicer?

**URL:** https://discourse.slicer.org/t/how-can-i-run-a-python-script-on-slicer/25527
**Category:** Support
**Created:** [October 3, 2022, 1:02pm UTC](https://discourse.slicer.org/t/how-can-i-run-a-python-script-on-slicer/25527 "2022-10-03T13:02:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![MarcoSaguatti](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@MarcoSaguatti](https://discourse.slicer.org/u/MarcoSaguatti)
#### Post date: [October 3, 2022, 1:02pm UTC](https://discourse.slicer.org/t/how-can-i-run-a-python-script-on-slicer/25527/1 "2022-10-03T13:02:12Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [October 3, 2022, 3:21pm UTC](https://discourse.slicer.org/t/how-can-i-run-a-python-script-on-slicer/25527/2 "2022-10-03T15:21:55Z")

</div>

You could run

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

```

from the Python Interactor.
