# Module executable file

**URL:** https://discourse.slicer.org/t/module-executable-file/17128
**Category:** Support
**Created:** [April 16, 2021, 11:28am UTC](https://discourse.slicer.org/t/module-executable-file/17128 "2021-04-16T11:28:49Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)
#### Post date: [April 16, 2021, 11:28am UTC](https://discourse.slicer.org/t/module-executable-file/17128/1 "2021-04-16T11:28:49Z")

</div>

Hi everyone,

I developed a python scriped module using the Extension Wizard module in 3D Slicer (4.13.0) which takes as inputs the PatientID and a 3D volume. The module is running when the user clicks on the “Run” button.  
Is it possible to convert the module into an executable file to run the module on another PC without sharing the source code?

Thank you in advance.

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [April 16, 2021, 11:46am UTC](https://discourse.slicer.org/t/module-executable-file/17128/2 "2021-04-16T11:46:06Z")

</div>

I believe for that you’d need to port your source code to C++, and if you want to move away from the open-source paradigm, then you won’t want the “download Slicer, install extension via extension manager” steps either, so maybe a Slicer custom app would be the best way to go.

---

<div class="post-metadata">

### Author: ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)
#### Post date: [April 17, 2021, 8:38am UTC](https://discourse.slicer.org/t/module-executable-file/17128/3 "2021-04-17T08:38:45Z")

</div>

Hello,

Thank you very much for your suggestion, it’s what I am looking for!

I looked into this tutorial [SlicerCAT: Creating custom applications based on 3D Slicer - Kitware Blog](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/) and followed the build instructions available in 3D Slicer documentation [Build Instructions — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/build_instructions/index.html).

I’m having the same problem as [Problem in building SlicerCustomAppTemplate - #5 by Pooja\_Virkar](https://discourse.slicer.org/t/problem-in-building-slicercustomapptemplate/9783/5) : there is no file in the Slicer-build directory, so I couldn’t run /Slicer-build/Slicer.exe. I didn’t understand what was done to solve it, could you please explain it to me?

---

<div class="post-metadata">

### Author: ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)
#### Post date: [April 19, 2021, 10:16pm UTC](https://discourse.slicer.org/t/module-executable-file/17128/4 "2021-04-19T22:16:06Z")

</div>

I managed to get the executable file but the DICOM module was not loaded although it was enabled at the cmakefile.txt

# Enable Slicer built-in modules

set(Slicer\_QTLOADABLEMODULES\_ENABLED  
)  
set(Slicer\_QTSCRIPTEDMODULES\_ENABLED  
DICOM  
DICOMLib  
DICOMPatcher  
DICOMPlugins  
)

And I’m getting the following error loading the scripted module:

for patient in slicer.dicomDatabase.patients():

AttributeError: module ‘slicer’ has no attribute ‘dicomDatabase’

Am I doing something wrong? I would appreciate some help. Thanks.

---

<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: [April 19, 2021, 10:44pm UTC](https://discourse.slicer.org/t/module-executable-file/17128/5 "2021-04-19T22:44:50Z")

</div>

You need to go to the DICOM module at least once to ensure that a valid DICOM database is created.

---

<div class="post-metadata">

### Author: ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)
#### Post date: [April 19, 2021, 11:14pm UTC](https://discourse.slicer.org/t/module-executable-file/17128/6 "2021-04-19T23:14:22Z")

</div>

But I can’t go to the DICOM module

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/8/a8302d5634fd654b9ce9466a8447d31908fd76c2.png)

Maybe there was any problem during the build? I didn’t get any error message…

---

<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: [April 19, 2021, 11:15pm UTC](https://discourse.slicer.org/t/module-executable-file/17128/7 "2021-04-19T23:15:25Z")

</div>

Have you had any build errors? If not then you may have disabled DICOM support in your CMake files (CMakeLists.txt an \*.cmake files) in your custom application source code.

---

<div class="post-metadata">

### Author: ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)
#### Post date: [April 21, 2021, 7:54am UTC](https://discourse.slicer.org/t/module-executable-file/17128/8 "2021-04-21T07:54:10Z")

</div>

Hi Andras, thank you for your response. Now I manage to get the DICOM module but I’m still getting the same error. I don’t understand why because from python interaction the application finds the DICOM database.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/4/94629a3f4618f45db09cf279d70b630e8548ce39.png)

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [April 21, 2021, 8:07am UTC](https://discourse.slicer.org/t/module-executable-file/17128/9 "2021-04-21T08:07:32Z")

</div>

It is possible you are trying to access it too early. Maybe do some of the setup in the module widget’s `setup` function. Or connect a slot to the `startupCompleted` signal and do it there. To connect:

`slicer.app.connect("startupCompleted()", self.onStartupCompleted)`

---

<div class="post-metadata">

### Author: ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)
#### Post date: [April 21, 2021, 8:30am UTC](https://discourse.slicer.org/t/module-executable-file/17128/10 "2021-04-21T08:30:32Z")

</div>

Thank you very much! It solved my problem!

---

<div class="post-metadata">

### Author: ![marianaslicer](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/marianaslicer/32/8555_2.png) [@marianaslicer](https://discourse.slicer.org/u/marianaslicer)
#### Post date: [April 21, 2021, 9:01am UTC](https://discourse.slicer.org/t/module-executable-file/17128/11 "2021-04-21T09:01:30Z")

</div>

I have another question: I added to the ElastixParameterSetDatabase file a specific preset to be used in the registration. Should I re-build the project to compile the new preset?  
Thanks

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [April 21, 2021, 9:34am UTC](https://discourse.slicer.org/t/module-executable-file/17128/12 "2021-04-21T09:34:39Z")

</div>

Can you please create a new topic for easier discoverability? If we discuss more, unrelated questions in the same thread people won’t have the chance to find it if they have the same issue…
