# Slicer in a python pipeline (but not in the slicer python interpretor)

**URL:** https://discourse.slicer.org/t/slicer-in-a-python-pipeline-but-not-in-the-slicer-python-interpretor/24709
**Category:** Development
**Created:** [August 10, 2022, 12:46pm UTC](https://discourse.slicer.org/t/slicer-in-a-python-pipeline-but-not-in-the-slicer-python-interpretor/24709 "2022-08-10T12:46:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jean\_Jacquemier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jean_jacquemier/32/15947_2.png) [@Jean\_Jacquemier](https://discourse.slicer.org/u/Jean_Jacquemier)
#### Post date: [August 10, 2022, 12:46pm UTC](https://discourse.slicer.org/t/slicer-in-a-python-pipeline-but-not-in-the-slicer-python-interpretor/24709/1 "2022-08-10T12:46:08Z")

</div>

I would like to use slicer in a python pipeline that will be executed on a large cluster in a batch mode.

I succeed to execute the python code on my laptop:

- thanks to the Slicer3D JupyterKernel kernel extention.
- thanks to a external python env, throw jupyter (after having executing this command `jupyter-kernelspec install "/home/jacquemi/usr/local/Slicer-5.0.2-linux-amd64/NA-MIC/Extensions-30822/SlicerJupyter/share/Slicer-5.0/qt-loadable-modules/JupyterKernel/Slicer-5.0" --replace --user`)

But I did not succeed to install slicer (using pip or whatever) in an external Python virtualenv without using jupyter. As I need to execute my pipeline into a cluster in batch mode, I cannot use neither Jupyter nor the 3D slicer python interpreter

So is there a way to install slicer Python library in a virtual  
venv and to load (and use) it in a simple python session (not a jupyter one) ?

This [documentation](https://slicer.readthedocs.io/en/latest/developer_guide/build_instructions/overview.html) indicates that : “Python scripting and development of new Slicer modules in Python does not require building the application either”  
.

---

<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 10, 2022, 2:01pm UTC](https://discourse.slicer.org/t/slicer-in-a-python-pipeline-but-not-in-the-slicer-python-interpretor/24709/2 "2022-08-10T14:01:14Z")

</div>

> [@Jean\_Jacquemier](#):
>
> So is there a way to install slicer Python library in a virtual  
> venv and to load (and use) it in a simple python session (not a jupyter one) ?

No, Slicer needs to use Slicer’s python build for all the dependencies to work. You should be able to run Slicer from a directory available to your cluster node. You can use xvfb to get an X session if it’s not available on your node. This requires some memory (real or virtual) on the node, but this is usually manageable and small compared to a large computing task requirement.

> [@Jean\_Jacquemier](#):
>
> This [documentation](https://slicer.readthedocs.io/en/latest/developer_guide/build_instructions/overview.html) indicates that : “Python scripting and development of new Slicer modules in Python does not require building the application either”

That means you can use Slicer’s python to develop Slicer modules, but you still need Slicer itself.

As a future goal we’d like to support installing parts of Slicer as packages for standard python systems but this isn’t possible currently.
