Trying to run test from loadable module (outside of Slicer source tree)

Hi everyone,

I’m trying to develop a loadable module outside of Slicer source tree using a configuration based on the wiki tutorial. I have gotten to import the module and compile in QtCreator but I have a problem running the test.

In the first time, when I run the test, it tries to call to ‘’ in the module bin directory instead of in the Slicer directory. I created a LauncheSettings.ini based in the Slicer’s launcher settings file but It does not look for in the correct directory although I created the SLICER_HOME variable. Anyway, I created that variable in QtCreator’s enviroment and It works but during the execution console throws multiple errors about import python command.

Here i let you the first lines from Console:
Traceback (most recent call last):
File “”, line 7, in
File “/home/abian/Datos/Slicer/Slicer-Build-Debug/Slicer-build/bin/Python/slicer/”, line 4, in
import ctk
ImportError: No module named ctk
Traceback (most recent call last):
File “”, line 7, in
File “/home/abian/Datos/Slicer/Slicer-Build-Debug/Slicer-build/bin/Python/slicer/”, line 42, in
slicer.sliceWidgets = {}
NameError: name ‘slicer’ is not defined
ImportError: No module named slicer

I don’t sure where is the problem but I’m trying to run the generic test that ExtensionWizard script created. If someone can help me, I will be grateful.

I’m working on Ubuntu 16.04, Slicer 4.9 compiled with Qt 5.9.2 and GCC 5.4. If you need it, the QtCreator version is 4.4.1.


Looks like ctk didn’t build or wasn’t found at startup.

Best thing would be to get the standard build of Slicer working and then introduce your loadable module using the --additional-module-paths command line option or by setting the module preferences.

You shouldn’t ever need to set SLICER_HOME directly (always use the launcher instead).


Thanks for your answer. The --additional-module-paths command line works perfectly but my idea was not to use the standard build in order to avoid to load every modules, maybe i need to debug my module and the waiting for slicer to start could be annoying.

I was debugging slicer to understand the launcher setting and to check if it is selecting the correct file. I saw that SLICER_HOME variable is changed by my LauncherSetting.ini value but he ignored it and it still looking for in the wrong directory.

Traceback (most recent call last):
  File "<string>", line 7, in <module>
IOError: [Errno 2] No such file or directory: '/mnt/Aux/Slicer/Extensions/MyExtension-Build-Debug/bin/Python/slicer/'
Traceback (most recent call last):
  File "<string>", line 7, in <module>
IOError: [Errno 2] No such file or directory: '/mnt/Aux/Slicer/Extensions/MyExtension-Build-Debug/bin/Python/slicer/

I attached captures of my LauncherSetting.ini: Screenshot_20171206_164825 Screenshot_20171206_164855

Anyway, i can work with the --additional-module-paths command line but i want to know why i cant use the generic test generated by the ExtensionWIzard.

Slicer startup time should be under 10 seconds, but if that’s too much then when you build Slicer you can specify a list of modules to exclude from build.

Maybe something needs to be fixed - if you start with a standard build and create a loadable extension with the wizard you should be able to run the tests.

Hi Andras,

In my case, i want to use volumes from Slicer and I am debugging in order to understand better the Slicer architecture and how works the volumes module. In debug, Slicer startup time take a little bit more time.

Anyway, I could take a build excluding modules that I will not use. Thanks for your answer.

I will try to use the extension inside of Slicer source tree… Maybe my problem is due to the configuration of my extension outside of the slicer.