Create installer package with extension and configuration

Hello Every one,

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

I have followed the tutorial in

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”)?

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

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 个 ==========

If you want to bundle an extension in your custom install package then the recommend method is to use the Slicer Custom Application Template.

Hello Iassoan,

This really a good tools,

I am going to try it~

Thank you very much!

Hello Iassoan,

Thank you for your instruction and recommend this method to me.( Slicer Custom Application Template)

I have followed the method below.

  1. Generate the application framework from the template repository
  2. Customize the Slicer configuration using CMake (optional)
  3. Add new custom modules (optional)
  4. Build the custom app

If I don’t execute the 3ed step “3. Add new custom modules (optional)”, everything goes okay, And I can build and get an example executable file. image

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

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:

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

I have solved this problem.

There are some problems with my custom modules.

Now It works,

Thank you!

1 Like

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/

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.

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.

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~