# How to run python based CLI modules?

**URL:** <https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627>\
**Category:** Support\
**Created:** [November 4, 2018, 5:08am UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627 "2018-11-04T05:08:59Z")\
**Posts on this page:** 11\
**Page:** 2

<div class="post-metadata">

**Author:** ![Thu\_n\_Chu\_th](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thu_n_chu_th/32/9542_2.png) [@Thu\_n\_Chu\_th](https://discourse.slicer.org/u/Thu_n_Chu_th)\
**Post date:** [August 2, 2022, 3:14pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/21 "2022-08-02T15:14:31Z")

</div>

i have a little question.  
do these parts need to install more cmake?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 2, 2022, 3:18pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/22 "2022-08-02T15:18:51Z")

</div>

No, not if you do everything in python.

---

<div class="post-metadata">

**Author:** ![Thu\_n\_Chu\_th](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thu_n_chu_th/32/9542_2.png) [@Thu\_n\_Chu\_th](https://discourse.slicer.org/u/Thu_n_Chu_th)\
**Post date:** [August 2, 2022, 4:06pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/23 "2022-08-02T16:06:44Z")

</div>

Can you give me a tutorial or link on how to combine python code into 3D slicer?  
I’ve read a lot of ways but still don’t know how to do it.  
Since I am still a student, my ability to analyze documents is still a bit poor. hope you can help me.

---

<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:** [August 2, 2022, 4:25pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/24 "2022-08-02T16:25:00Z")

</div>

Sure - open the Python interactor:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/1/c13de5b897fe02a565130c41061bfbd7f0de5bd7.png)

and enter some Python code.

A good starting point for reading is:

[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html)

Copy/paste source code from that page into the Python interactor.

If you want to integrate deep learning source code into 3D Slicer you will probably need a programmer.

---

<div class="post-metadata">

**Author:** ![Thu\_n\_Chu\_th](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thu_n_chu_th/32/9542_2.png) [@Thu\_n\_Chu\_th](https://discourse.slicer.org/u/Thu_n_Chu_th)\
**Post date:** [August 2, 2022, 4:26pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/25 "2022-08-02T16:26:37Z")

</div>

hi Rbumm!  
thankyou so much.

---

<div class="post-metadata">

**Author:** ![Thu\_n\_Chu\_th](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thu_n_chu_th/32/9542_2.png) [@Thu\_n\_Chu\_th](https://discourse.slicer.org/u/Thu_n_Chu_th)\
**Post date:** [August 2, 2022, 4:29pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/26 "2022-08-02T16:29:05Z")

</div>

Can I ask if the integration of deep learning code is also done on Python interactor?

---

<div class="post-metadata">

**Author:** ![Thu\_n\_Chu\_th](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thu_n_chu_th/32/9542_2.png) [@Thu\_n\_Chu\_th](https://discourse.slicer.org/u/Thu_n_Chu_th)\
**Post date:** [August 2, 2022, 4:32pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/27 "2022-08-02T16:32:19Z")

</div>

![slicer](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/2/424d06e935554361010dc829968294d1952e2ba8.png)  
i tried integrating deep learning in this way, but i don’t know is it correct?

---

<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:** [August 2, 2022, 4:33pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/28 "2022-08-02T16:33:52Z")

</div>

If your deep learning code is written in Python - it probably is. You would need to write a program in Python language and load and test it via the Python interactor.

---

<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:** [August 2, 2022, 4:34pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/29 "2022-08-02T16:34:59Z")

</div>

This would be a starting point to write your own 3D Slicer extension.

Please remember that this forum is not a chat program and every question you ask pushes the thread up to the beginning again.

---

<div class="post-metadata">

**Author:** ![Thu\_n\_Chu\_th](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thu_n_chu_th/32/9542_2.png) [@Thu\_n\_Chu\_th](https://discourse.slicer.org/u/Thu_n_Chu_th)\
**Post date:** [August 2, 2022, 4:39pm UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/30 "2022-08-02T16:39:59Z")

</div>

sorry so much, I’ll keep an eye on this.

---

<div class="post-metadata">

**Author:** ![Saima](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Saima](https://discourse.slicer.org/u/Saima)\
**Post date:** [October 17, 2023, 5:23am UTC](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627/31 "2023-10-17T05:23:40Z")

</div>

Hi Andras,  
I am working on running the radiomics cli for batch processing. I want to update the binwidth. I have the following code.

how can I define the binwidth using params.

```auto
 params = {}
            params["Image"] = slicer.util.getNode(apt_data.GetID())
            params["Mask"] = slicer.util.getNode(seg.GetID())
            params["param"] = directoryPath+"/param_file.file.yaml" this line is not working when I run default without passing file it works. 
            params["out"] = t
cliModule = slicer.modules.slicerradiomicscli
                cliNode = slicer.cli.runSync(cliModule, None, params)

```

regards,  
Saima

[Previous page](https://discourse.slicer.org/t/how-to-run-python-based-cli-modules/4627.md?page=1)
