# How can I write a python CLI code using slicer internal module

**URL:** <https://discourse.slicer.org/t/how-can-i-write-a-python-cli-code-using-slicer-internal-module/18023>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [June 8, 2021, 8:10pm UTC](https://discourse.slicer.org/t/how-can-i-write-a-python-cli-code-using-slicer-internal-module/18023 "2021-06-08T20:10:36Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 9, 2021, 4:56am UTC](https://discourse.slicer.org/t/how-can-i-write-a-python-cli-code-using-slicer-internal-module/18023/3 "2021-06-09T04:56:10Z")

</div>

CLI modules are Python scripts or command-line applications that do not rely on Slicer. They can be executed within Slicer’s environment or without Slicer. What Slicer offers is displaying automatically-generated GUI, writing all inputs to file, executing the application, continuous progress reporting, and in the end reading back all outputs into the scene.

The automatically generated GUI is typically convenient enough for development, testing, and research/engineering use. For clinical use, often a Python scripted loadable module is developed as a front-end, which provides a more sophisticated GUI and calls the CLI module in the background.

To designate an output image as labelmap, specify `type="label"`, as it is done for example in ModelToLabelMap module:

> <https://github.com/Slicer/Slicer/blob/e6971c540b030f7e83f949918a433cf58bee4c3b/Modules/CLI/ModelToLabelMap/ModelToLabelMap.xml#L45>

---

_[View the full topic](https://discourse.slicer.org/t/how-can-i-write-a-python-cli-code-using-slicer-internal-module/18023)._
