# Failing Tests - ImportError: No module named Elastix

**URL:** <https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202>\
**Category:** Development\
**Created:** [June 17, 2019, 2:27pm UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202 "2019-06-17T14:27:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [June 17, 2019, 2:27pm UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/1 "2019-06-17T14:27:50Z")

</div>

There a couple extensions with failing tests for Slicer 4.10 related to a failure to import Elastix.

SequenceRegistration: [http://slicer.cdash.org/testDetails.php?test=9620798&build=1619449](http://slicer.cdash.org/testDetails.php?test=9620798&build=1619449)  
SlicerCochlea: [http://slicer.cdash.org/testDetails.php?test=9662089&build=1619496](http://slicer.cdash.org/testDetails.php?test=9662089&build=1619496)

```auto
test_widgetRepresentation (qSlicerSequenceRegistrationModuleGenericTest.qSlicerSequenceRegistrationModuleGenericTest) ... Traceback (most recent call last):
  File "/Volumes/Dashboards/Stable/S-4102-E-b/SequenceRegistration-build/lib/Slicer-4.10/qt-scripted-modules/SequenceRegistration.py", line 42, in setup
    self.logic = SequenceRegistrationLogic()
  File "/Volumes/Dashboards/Stable/S-4102-E-b/SequenceRegistration-build/lib/Slicer-4.10/qt-scripted-modules/SequenceRegistration.py", line 490, in __init__
    import Elastix
ImportError: No module named Elastix
ok

```

The .s4ext files on the 4.10 branch do specify SlicerElastix as a dependency. SequenceRegistration specifies SlicerElastix as a dependency [here](https://github.com/Slicer/ExtensionsIndex/blob/4.10/SequenceRegistration.s4ext#L15). Anyone have an idea about why it is failing to import Elastix? Something specific to the build/test process on the nightly builds of extensions?

---

<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:** [June 17, 2019, 3:37pm UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/2 "2019-06-17T15:37:18Z")

</div>

If SlicerElastix extension is installed them `import Elastix` should not throw an error. SlicerElastix is built successfully for Slicer-4.10.x and also for recent Slicer-4.11.x releases. I only see occasional build errors on Linux (dashboard upload fails, so it is not really a build error but some issue on the factory machine).

If an extension uses SlicerElastix and does not list it as a dependency then maybe the expectation is that the user will install it manually? Probably it would be better to list it as a dependency.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [June 17, 2019, 3:49pm UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/3 "2019-06-17T15:49:04Z")

</div>

I didn’t see any import issues with the extension installed, but it appears the failing test for `ImportError: No module named Elastix` has been happening since at least 2018.

The extensions are both listing SlicerElastix as a dependency.

@jcfr Is this some issue with the factory machine?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 18, 2019, 7:05am UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/4 "2019-06-18T07:05:59Z")

</div>

> but it appears the failing test for `ImportError: No module named Elastix`

This should be fixed in [ENH: Generate SlicerElastixConfig to fix find\_package() call by dependent extension by jcfr · Pull Request #18 · lassoan/SlicerElastix · GitHub](https://github.com/lassoan/SlicerElastix/pull/18)

After integrating this change, the following tests are still failing but this is independent of SlicerElastix:

```plaintext
$ ctest 
Test project /tmp/SlicerCochlea-build
    Start 1: py_nomainwindow_qSlicerCochleaRegModuleGenericTest
1/9 Test #1: py_nomainwindow_qSlicerCochleaRegModuleGenericTest ..... Passed 16.88 sec
    Start 2: py_CochleaReg
2/9 Test #2: py_CochleaReg ..........................................***Failed 3.77 sec
    Start 3: py_CochleaRegModuleTest
3/9 Test #3: py_CochleaRegModuleTest ................................***Failed 82.24 sec
    Start 4: py_nomainwindow_qSlicerCochleaSegModuleGenericTest
4/9 Test #4: py_nomainwindow_qSlicerCochleaSegModuleGenericTest ..... Passed 2.74 sec
    Start 5: py_CochleaSeg
5/9 Test #5: py_CochleaSeg ..........................................***Failed 3.77 sec
    Start 6: py_CochleaSegModuleTest
6/9 Test #6: py_CochleaSegModuleTest ................................***Failed 47.83 sec
    Start 7: py_nomainwindow_qSlicerVisSimCommonModuleGenericTest
7/9 Test #7: py_nomainwindow_qSlicerVisSimCommonModuleGenericTest ... Passed 2.85 sec
    Start 8: py_VisSimCommon
8/9 Test #8: py_VisSimCommon ........................................ Passed 3.65 sec
    Start 9: py_VisSimCommonModuleTest
9/9 Test #9: py_VisSimCommonModuleTest .............................. Passed 3.88 sec

```

I submitted the following PR to simplify the testing harness and fix the one of the failing tests, the last failing test can be fixed applying similar fixes (cc: @brhoom) . See [Fix CochleaReg test by jcfr · Pull Request #17 · MedicalImageAnalysisTutorials/SlicerCochlea · GitHub](https://github.com/MedicalImageAnalysisTutorials/SlicerCochlea/pull/17)

```plaintext
$ ctest 
Test project /tmp/SlicerCochlea-build
    Start 1: py_nomainwindow_qSlicerCochleaRegModuleGenericTest
1/7 Test #1: py_nomainwindow_qSlicerCochleaRegModuleGenericTest ..... Passed 2.83 sec
    Start 2: py_CochleaReg
2/7 Test #2: py_CochleaReg .......................................... Passed 22.38 sec
    Start 3: py_nomainwindow_qSlicerCochleaSegModuleGenericTest
3/7 Test #3: py_nomainwindow_qSlicerCochleaSegModuleGenericTest ..... Passed 2.85 sec
    Start 4: py_CochleaSeg
4/7 Test #4: py_CochleaSeg ..........................................***Failed 3.80 sec
    Start 5: py_nomainwindow_qSlicerVisSimCommonModuleGenericTest
5/7 Test #5: py_nomainwindow_qSlicerVisSimCommonModuleGenericTest ... Passed 2.76 sec
    Start 6: py_VisSimCommon
6/7 Test #6: py_VisSimCommon ........................................ Passed 3.65 sec
    Start 7: py_VisSimCommonModuleTest
7/7 Test #7: py_VisSimCommonModuleTest .............................. Passed 3.77 sec

```

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [June 18, 2019, 7:49am UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/5 "2019-06-18T07:49:21Z")

</div>

> This should be fixed in [ENH: Generate SlicerElastixConfig to fix find\_package() call by dependent extension by jcfr · Pull Request #18 · lassoan/SlicerElastix · GitHub](https://github.com/lassoan/SlicerElastix/pull/18)

Thanks for your effort. I got this error, while I am testing your modifications now. I got this error:

```
                CochleaReg.py", line 398, in testSlicerCochleaRegistration
checksums='SHA256:d7cda4e106294a59591f03e74fbe9ecffa322dd1a9010b4d0590b377acc05eb5')[0]
               TypeError: downloadFromURL() got an unexpected keyword argument 'checksums'
               Reload and Test: Exception!

              downloadFromURL() got an unexpected keyword argument 'checksums'

```

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [June 18, 2019, 8:02am UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/6 "2019-06-18T08:02:45Z")

</div>

Solved by changing the code to:

```
  nodeNames='P100001_DV_L_a'
  nodeNames='P100001_DV_L_a'
  fileNames='P100001_DV_L_a.nrrd'
  uris='https://cloud.uni-koblenz-landau.de/s/EwQiQidXqTcGySB/download'
  checksums='SHA256:d7cda4e106294a59591f03e74fbe9ecffa322dd1a9010b4d0590b377acc05eb5'
  if fixedImgPath is None:
      fixedVolumeNode = SampleData.downloadFromURL(uris, fileNames, nodeNames, checksums )[0]
```

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [June 18, 2019, 11:26am UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/7 "2019-06-18T11:26:49Z")

</div>

@brhoom Did you test with a recent Slicer build? Checksum support was added to the SampleData module 6 days ago. See [https://github.com/Slicer/Slicer/commit/aedb7d6702a30b485be952f2c933dfd96f072f02](https://github.com/Slicer/Slicer/commit/aedb7d6702a30b485be952f2c933dfd96f072f02)

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 18, 2019, 1:29pm UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/8 "2019-06-18T13:29:59Z")

</div>

As indicated by @jamesobutler, since the checksum has been introduced recently, make sure to use a recent Slicer version.

Only after all issues have been addressed in the `master` branch, I suggest you backport changes to the `4.10`

---

<div class="post-metadata">

**Author:** ![brhoom](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/brhoom/32/1228_2.png) [@brhoom](https://discourse.slicer.org/u/brhoom)\
**Post date:** [June 18, 2019, 2:30pm UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/9 "2019-06-18T14:30:33Z")

</div>

The error was in 4.11.

I have another issue. By using simpledata , the volume has no storage node anymore. I find a workaround be reloading the volume.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 18, 2019, 3:01pm UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/10 "2019-06-18T15:01:26Z")

</div>

> I find a workaround be reloading the volume.

Since the downloaded data are for testing … keeping the storage node would not give the opportunity for the user to save in a location different from the tmp folder.

Updating the `CochleaReg` module, I noticed you were relaying on the filename associated with the storage node to restore the node name.

Without revisiting the approach, here what i did to make sure the storage node was available:

> <https://github.com/MedicalImageAnalysisTutorials/SlicerCochlea/blob/28789608f9fc35deb5ccd8ab4936e7790ff54d84/CochleaReg/CochleaReg.py#L279-L282>

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 18, 2019, 6:52pm UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/11 "2019-06-18T18:52:25Z")

</div>

@brhoom This commit should fix the remaining test, I will let you cherry-pick what makes sense. See [https://github.com/jcfr/SlicerCochlea/commit/30e61b013582e54fe940a63f2180050420fbe1ec](https://github.com/jcfr/SlicerCochlea/commit/30e61b013582e54fe940a63f2180050420fbe1ec)

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 18, 2019, 6:55pm UTC](https://discourse.slicer.org/t/failing-tests-importerror-no-module-named-elastix/7202/12 "2019-06-18T18:55:15Z")

</div>

Summary:

- issue preventing the Elastix module from being available in SlicerCochlea has been fixed in [https://github.com/lassoan/SlicerElastix/pull/18](https://github.com/lassoan/SlicerElastix/pull/18)
- redundant and unused test script have been removed from SlicerCochlea
- failing `py_CochleaReg` test has been fixed in [https://github.com/MedicalImageAnalysisTutorials/SlicerCochlea/pull/17](https://github.com/MedicalImageAnalysisTutorials/SlicerCochlea/pull/17)
- failing test `py_CochleaSeg` has been fixed in [SlicerCochlea@b50284d1](https://github.com/MedicalImageAnalysisTutorials/SlicerCochlea/commit/b50284d1a1cb552a7ee38902ded33fd9e5977c6b), with improvements suggested in [jcfr/SlicerCochlea@30e61b013](https://github.com/jcfr/SlicerCochlea/commit/30e61b013582e54fe940a63f2180050420fbe1ec)
