# Scripting Slicer - What is possible?

**URL:** <https://discourse.slicer.org/t/scripting-slicer-what-is-possible/16873>\
**Category:** Support\
**Created:** [March 31, 2021, 10:45am UTC](https://discourse.slicer.org/t/scripting-slicer-what-is-possible/16873 "2021-03-31T10:45:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hball99](https://avatars.discourse-cdn.com/v4/letter/h/7cd45c/32.png) [@Hball99](https://discourse.slicer.org/u/Hball99)\
**Post date:** [March 31, 2021, 10:45am UTC](https://discourse.slicer.org/t/scripting-slicer-what-is-possible/16873/1 "2021-03-31T10:45:08Z")

</div>

Hello there!  
I am quite new to Slicer and I am having difficulties to understand what is actually possible with Slicer Scripting and what not.

So my problem is the following: I know that I can script modules that I can import into Slicer GUI. But what I want to do, is to use all the slicer functions in a seperate python script outside of the Slicer GUI by just importing the module “slicer”.

I have seen that there is a big script repository at  
[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository)  
but is that a script repository only for slicer modules? Or can I use all those functions also in arbitrary python scripts as long as I import slicer correctly?

If that would be possible, I have another question regarding the installation of slicer. Right now, I have just downloaded slicer from the homepage [https://download.slicer.org/](https://download.slicer.org/). But then there is a different installation guide for developers at [Windows — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/build_instructions/windows.html) .  
Do I have to install that on top of the regular programm or instead? Or don’t I need that at all? Because I cannot figure out how to import slicer packages into any python script.

I hope I was able to tell what exactly my problem is. Also sorry, I am quite new to all of this. To give a bit of context: my ultimate goal is to script the problem that I have 200 .nrrd Segementations that I want to convert to nii.gz (Labelmap-) Volumes while being able to define a reference Volume for each Segmentation.

Thanks in advance!

---

<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:** [March 31, 2021, 5:17pm UTC](https://discourse.slicer.org/t/scripting-slicer-what-is-possible/16873/2 "2021-03-31T17:17:06Z")

</div>

Slicer has a built-in python, but we don’t package slicer something you can import into other python environments (we’ve talked about this as a goal, but it’s not the way things are now).

So any of the example scripts expect you to have a slicer environment to operate in. If you start slicer with the `--no-main-window` option and the `--python-script <script>.py` it will work like a regular python environment, or `Slicer --no-main-window --python-code "slicer.app.pythonConsole().show()"` will pop up a console with the slicer commands available but no other gui unless you create one.

HTH
