# Create installer package with extension and configuration

**URL:** <https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139>\
**Category:** Development\
**Tags:** installation\
**Created:** [December 19, 2020, 1:35am UTC](https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139 "2020-12-19T01:35:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tesla2678](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tesla2678/32/9062_2.png) [@Tesla2678](https://discourse.slicer.org/u/Tesla2678)\
**Post date:** [December 19, 2020, 1:35am UTC](https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139/1 "2020-12-19T01:35:04Z")

</div>

Hello Every one,

I have a question about how to create an installer package(With a created extension).

I have followed the tutorial in  
[https://slicer.readthedocs.io/en/latest/developer\_guide/build\_instructions/windows.html](https://slicer.readthedocs.io/en/latest/developer_guide/build_instructions/windows.html)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/e/6e35c681bed89db3ffa28e26ff11d036f16a2c03.png)

If I just follow the tutorial method, the installer package created does not include my extension.

So, How to configure and create an installer package with an extension( in folder “\Slicer-build\Modules\Scripted”)?

---

<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:** [December 19, 2020, 2:34am UTC](https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139/2 "2020-12-19T02:34:26Z")

</div>

Have you built Slicer?  
Did you get any error message?

---

<div class="post-metadata">

**Author:** ![Tesla2678](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tesla2678/32/9062_2.png) [@Tesla2678](https://discourse.slicer.org/u/Tesla2678)\
**Post date:** [December 19, 2020, 6:11am UTC](https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139/3 "2020-12-19T06:11:41Z")

</div>

Hello Iassoan,

Yes, I have built it, and successful without error.  
But after installing the Slicer from the “installer package”, The Module folder and Extensions disappeared.

##################################################  
77\>Qt5WebChannel.dll is up to date.  
77\>libGLESv2.dll is up to date.  
77\>libEGL.dll is up to date.  
77\>D3Dcompiler\_47.dll is up to date.  
77\>opengl32sw.dll is up to date.  
77\>Creating C:\Slicer\_new\Slicer-build\_CPack\_Packages\win-amd64\NSIS\Slicer-4.11.0-2020-07-04-win-amd64\bin\resources…  
77\>Updating icudtl.dat.  
77\>Updating qtwebengine\_devtools\_resources.pak.  
77\>Updating qtwebengine\_resources.pak.  
77\>Updating qtwebengine\_resources\_100p.pak.  
77\>Updating qtwebengine\_resources\_200p.pak.  
77\>Creating C:\Slicer\_new\Slicer-build\_CPack\_Packages\win-amd64\NSIS\Slicer-4.11.0-2020-07-04-win-amd64\bin\translations\qtwebengine\_locales…  
77\>Updating en-US.pak.  
77\>CPack: Create package  
77\>CPack: - package: C:/Slicer\_new/Slicer-build/Slicer-4.11.0-2020-07-04-win-amd64.exe generated.  
========== 生成: 成功 77 个，失败 0 个，最新 504 个，跳过 0 个 ==========

---

<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:** [December 19, 2020, 6:14am UTC](https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139/4 "2020-12-19T06:14:05Z")

</div>

If you want to bundle an extension in your custom install package then the recommend method is to use the [Slicer Custom Application Template](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/).

---

<div class="post-metadata">

**Author:** ![Tesla2678](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tesla2678/32/9062_2.png) [@Tesla2678](https://discourse.slicer.org/u/Tesla2678)\
**Post date:** [December 19, 2020, 7:48am UTC](https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139/5 "2020-12-19T07:48:55Z")

</div>

Hello Iassoan,

This really a good tools,

I am going to try it~

Thank you very much!

---

<div class="post-metadata">

**Author:** ![Tesla2678](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tesla2678/32/9062_2.png) [@Tesla2678](https://discourse.slicer.org/u/Tesla2678)\
**Post date:** [December 21, 2020, 4:27am UTC](https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139/6 "2020-12-21T04:27:46Z")

</div>

Hello Iassoan,

Thank you for your instruction and recommend this method to me.( [Slicer Custom Application Template](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/))

I have followed the method below.

1. [Generate the application framework from the template repository](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/#step1)
2. [Customize the Slicer configuration using CMake (optional)](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/#step2)
3. [Add new custom modules (optional)](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/#step5)
4. [Build the custom app](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/#step6)

If I don’t execute the 3ed step “3. [Add new custom modules (optional)](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/#step5)”, everything goes okay, And I can build and get an example executable file. ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/e/bef12652daeb65c256031c523e6c328ac8d5b1fa.png)

But After I added my custom module “Reader” in CMakeLists.txt by this config(followed step 3):

set(Slicer\_EXTENSION\_SOURCE\_DIRS  
${AB\_SOURCE\_DIR}/Modules/Scripted/Reader  
)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/b/abf376bc5c85ec46b21399da8bcdbb3df73afaf9.png)

Then I can’t even build a project.

I suspect the reason maybe comes from my python modules, I imported some new modules in my custom module “Reader” such as PyTorch.

Then I added all needed python modules in “C:\ABB\python-install\Lib\site-packages”  
and then I can access it in python Interactor:

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

But I can’t rebuild it successfully. so, Can I get any to add a new module (with a new python package) in CMakeList?

---

<div class="post-metadata">

**Author:** ![Tesla2678](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tesla2678/32/9062_2.png) [@Tesla2678](https://discourse.slicer.org/u/Tesla2678)\
**Post date:** [December 22, 2020, 3:28am UTC](https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139/7 "2020-12-22T03:28:25Z")

</div>

I have solved this problem.

There are some problems with my custom modules.

Now It works,

Thank you!

---

<div class="post-metadata">

**Author:** ![Tesla2678](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tesla2678/32/9062_2.png) [@Tesla2678](https://discourse.slicer.org/u/Tesla2678)\
**Post date:** [December 28, 2020, 12:31am UTC](https://discourse.slicer.org/t/create-installer-package-with-extension-and-configuration/15139/8 "2020-12-28T00:31:13Z")

</div>

Hello Iassoan,

Thank you for your help these days. My work nearly finishes, just 2 problems left.  
I have built the custom project partly successful (include some new python packages like PyQt5 and Matplotlib).  
While I met 2 problems. One is about the custom building, the other one is about the build-installer-package.

**1、Problem about custom building.**  
I followed the step in [https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/)

The building process is successful. I got an “AB.exe” file in the “Slicer-build” folder.

When I open it(AB.exe), I found some of my custom configs( such as rename the title from ‘AB’ to ‘Reader’) in my extension module (I set it as the default startup module) work well at the beginning. And then my custom configs(the title “Reader”) were replaced by system original configs(“AB”) rapidly. So most of my custom configs were failed. (this problem just affect outlook, so I can still work on it)

**2、Problem about the “build-installer-package”**  
When I start to build installer-package as the follow instruct. even though the installer-package was built successfully, but after I install and open it some problems will happen.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/b/5b1c550eafce3a2c11289d80985f3e9ccb05b667.png)

On one of my computers, it can’t be started.  
On another computer, I started, but some bugs about the Python package raised. Shows below.

> ```
> Traceback (most recent call last):
> File "<string>", line 1, in <module>
> File "D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\imp.py", line 170, in load_source
> module = _exec(spec, sys.modules[name])
> File "<frozen importlib._bootstrap>", line 618, in _exec
> File "<frozen importlib._bootstrap_external>", line 678, in exec_module
> File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
> File "D:/Program Files/AB 0.1.0-0000-00-00/bin/../lib/AB-4.13/qt-scripted-modules/Reader.py", line 22, in <module>
> from PyQt5 import QtCore,Qt,QtGui
> ImportError: DLL load failed: The specified module could not be found.
> 
> ```

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

So, for Problem 1, I guess it may about the starting sequence.  
for Problem 2, I have no idea. It might about the method of built installer\_package. I want to assure, I have a new module in slicer, then the create install\_package process show start by “Slicer.exe --VisualStudioProject” is it right? maybe something wrong in here?  
It is not only the problem with the PyQt5 package. (I have tried to move code “from PyQt5 import QtCore,Qt,QtGui” to back of other code, another package got a problem)

> Traceback (most recent call last):  
> File “”, line 1, in   
> File “D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\imp.py”, line 170, in load\_source  
> module = \_exec(spec, sys.modules[name])  
> File “”, line 618, in \_exec  
> File “”, line 678, in exec\_module  
> File “”, line 219, in \_call\_with\_frames\_removed  
> File “D:/Program Files/AB 0.1.0-0000-00-00/bin/…/lib/AB-4.13/qt-scripted-modules/Reader.py”, line 45, in   
> from matplotlib import pyplot as pp  
> File “D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\site-packages\matplotlib\pyplot.py”, line 115, in   
> \_backend\_mod, new\_figure\_manager, draw\_if\_interactive, _show = pylab\_setup()  
> File "D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\site-packages\matplotlib\backends\_init_.py", line 62, in pylab\_setup  
> [backend\_name], 0)  
> File “D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\site-packages\matplotlib\backends\backend\_tkagg.py”, line 4, in   
> from . import tkagg # Paint image to Tk photo blitter extension.  
> File “D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\site-packages\matplotlib\backends\tkagg.py”, line 5, in   
> from six.moves import tkinter as Tk  
> File “D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\site-packages\six.py”, line 92, in **get**  
> result = self.\_resolve()  
> File “D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\site-packages\six.py”, line 115, in \_resolve  
> return \_import\_module(self.mod)  
> File “D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\site-packages\six.py”, line 82, in _import\_module  
> **import** (name)  
> File "D:\Program Files\AB 0.1.0-0000-00-00\lib\Python\Lib\tkinter\_init_.py", line 36, in   
> import \_tkinter # If this fails your Python may not be configured for Tk  
> ModuleNotFoundError: No module named ‘\_tkinter’

Could you give me some advice to solve these problems?

Thanks again~
