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

**URL:** <https://discourse.slicer.org/t/trying-to-run-test-from-loadable-module-outside-of-slicer-source-tree/1582>\
**Category:** Development\
**Created:** [December 3, 2017, 7:53pm UTC](https://discourse.slicer.org/t/trying-to-run-test-from-loadable-module-outside-of-slicer-source-tree/1582 "2017-12-03T19:53:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SolidusAbi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/solidusabi/32/585_2.png) [@SolidusAbi](https://discourse.slicer.org/u/SolidusAbi)\
**Post date:** [December 3, 2017, 7:53pm UTC](https://discourse.slicer.org/t/trying-to-run-test-from-loadable-module-outside-of-slicer-source-tree/1582/1 "2017-12-03T19:53:59Z")

</div>

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 ‘[slicerqt.py](http://slicerqt.py)’ 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/slicerqt.py”, 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/slicerqt-with-tcl.py”, 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.

Thanks!!!

---

<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:** [December 5, 2017, 12:34am UTC](https://discourse.slicer.org/t/trying-to-run-test-from-loadable-module-outside-of-slicer-source-tree/1582/2 "2017-12-05T00:34:44Z")

</div>

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](https://github.com/commontk/AppLauncher) instead).

HTH

---

<div class="post-metadata">

**Author:** ![SolidusAbi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/solidusabi/32/585_2.png) [@SolidusAbi](https://discourse.slicer.org/u/SolidusAbi)\
**Post date:** [December 6, 2017, 4:58pm UTC](https://discourse.slicer.org/t/trying-to-run-test-from-loadable-module-outside-of-slicer-source-tree/1582/3 "2017-12-06T16:58:13Z")

</div>

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/slicerqt.py'
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/slicerqt-with-tcl.py

```

I attached captures of my LauncherSetting.ini:

 ![Screenshot_20171206_164825](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/3/d3464a4f64908044818c25078c356bf598b7f85d.png)

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.

---

<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 6, 2017, 8:02pm UTC](https://discourse.slicer.org/t/trying-to-run-test-from-loadable-module-outside-of-slicer-source-tree/1582/4 "2017-12-06T20:02:10Z")

</div>

> [@SolidusAbi](#):
>
> waiting for slicer to start could be annoying.

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.

---

<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:** [December 7, 2017, 1:06pm UTC](https://discourse.slicer.org/t/trying-to-run-test-from-loadable-module-outside-of-slicer-source-tree/1582/5 "2017-12-07T13:06:43Z")

</div>

> [@SolidusAbi](#):
>
> i cant use the generic test generated by the ExtensionWIzard.

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.

---

<div class="post-metadata">

**Author:** ![SolidusAbi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/solidusabi/32/585_2.png) [@SolidusAbi](https://discourse.slicer.org/u/SolidusAbi)\
**Post date:** [December 7, 2017, 4:02pm UTC](https://discourse.slicer.org/t/trying-to-run-test-from-loadable-module-outside-of-slicer-source-tree/1582/6 "2017-12-07T16:02:37Z")

</div>

> [@lassoan](#):
>
> Slicer startup time should be under 10 seconds

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.

---

<div class="post-metadata">

**Author:** ![SolidusAbi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/solidusabi/32/585_2.png) [@SolidusAbi](https://discourse.slicer.org/u/SolidusAbi)\
**Post date:** [December 7, 2017, 4:05pm UTC](https://discourse.slicer.org/t/trying-to-run-test-from-loadable-module-outside-of-slicer-source-tree/1582/7 "2017-12-07T16:05:27Z")

</div>

> [@pieper](#):
>
> 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.

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.
