# Error with new extension Elastix

**URL:** <https://discourse.slicer.org/t/error-with-new-extension-elastix/278>\
**Category:** Support\
**Tags:** registration\
**Created:** [May 6, 2017, 4:08pm UTC](https://discourse.slicer.org/t/error-with-new-extension-elastix/278 "2017-05-06T16:08:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KaiWei\_Han](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kaiwei_han/32/172_2.png) [@KaiWei\_Han](https://discourse.slicer.org/u/KaiWei_Han)\
**Post date:** [May 6, 2017, 4:08pm UTC](https://discourse.slicer.org/t/error-with-new-extension-elastix/278/1 "2017-05-06T16:08:10Z")

</div>

Operating system:MacOS 10.12.4  
Slicer version:Slicer-4.7.0-2017-05-02-macosx-amd64  
Expected behavior:successful registration between two volume  
Actual behavior:“KeyError: ‘LD\_LIBRARY\_PATH’”  
Hey there, I am trying to register with this new extension Elastix. I have installed the extension and the Elastix toolbox from its official website. I can call elastix successfully in the terminal. However, when I am trying to register two volume, I have got this error:

> Volume registration is started in working directory: /var/folders/z8/4grvc78d4nn0d4nhy2l4869w0000gn/T/Slicer/Elastix/20170507\_000009\_410  
> Register volumes…  
> Register volumes using: /Applications/elastix\_macosx64\_v4.8/bin/elastix: [‘-f’, u’/var/folders/z8/4grvc78d4nn0d4nhy2l4869w0000gn/T/Slicer/Elastix/20170507\_000009\_410/input/fixed.mha’, ‘-m’, u’/var/folders/z8/4grvc78d4nn0d4nhy2l4869w0000gn/T/Slicer/Elastix/20170507\_000009\_410/input/moving.mha’, ‘-out’, u’/var/folders/z8/4grvc78d4nn0d4nhy2l4869w0000gn/T/Slicer/Elastix/20170507\_000009\_410/result-transform’, ‘-p’, ‘/Applications/Slicer.app/Contents/Extensions-25996/SlicerElastix/lib/Slicer-4.7/qt-scripted-modules/Resources/RegistrationParameters/Parameters\_Rigid.txt’, ‘-p’, ‘/Applications/Slicer.app/Contents/Extensions-25996/SlicerElastix/lib/Slicer-4.7/qt-scripted-modules/Resources/RegistrationParameters/Parameters\_BSpline.txt’]  
> ‘LD\_LIBRARY\_PATH’  
> **Traceback (most recent call last):**  
> File “/Applications/Slicer.app/Contents/Extensions-25996/SlicerElastix/lib/Slicer-4.7/qt-scripted-modules/Elastix.py”, line 327, in onApplyButton  
> movingVolumeMaskNode = self.movingVolumeMaskSelector.currentNode())  
> File “/Applications/Slicer.app/Contents/Extensions-25996/SlicerElastix/lib/Slicer-4.7/qt-scripted-modules/Elastix.py”, line 556, in registerVolumes  
> ep = self.startElastix(inputParamsElastix)  
> File “/Applications/Slicer.app/Contents/Extensions-25996/SlicerElastix/lib/Slicer-4.7/qt-scripted-modules/Elastix.py”, line 466, in startElastix  
> return subprocess.Popen([executableFilePath] + cmdLineArguments, env=self.getElastixEnv(),  
> File “/Applications/Slicer.app/Contents/Extensions-25996/SlicerElastix/lib/Slicer-4.7/qt-scripted-modules/Elastix.py”, line 433, in getElastixEnv  
> elastixEnv[“LD\_LIBRARY\_PATH”] = elastixLibDir + os.pathsep + elastixEnv[“LD\_LIBRARY\_PATH”]  
> **KeyError: ‘LD\_LIBRARY\_PATH’**

I could not figure this problem out, Any help will be appreciated.  
Sincerely  
Kaiwei Han M.D.  
Department of Neurosurgery, Changzheng Hospital, Shanghai, China.

---

<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:** [May 6, 2017, 7:00pm UTC](https://discourse.slicer.org/t/error-with-new-extension-elastix/278/2 "2017-05-06T19:00:05Z")

</div>

I’ve made the path setup more robust, which hopefully will fix the problem.

To try the fix right now, update “/Applications/Slicer.app/Contents/Extensions-25996/SlicerElastix/lib/Slicer-4.7/qt-scripted-modules/Elastix.py” file on your computer: change `elastixEnv["LD_LIBRARY_PATH"]...` line to the one shown here: [https://github.com/lassoan/SlicerElastix/blob/master/Elastix/Elastix.py#L433](https://github.com/lassoan/SlicerElastix/blob/master/Elastix/Elastix.py#L433)

Or, use Slicer’s nightly version that you download tomorrow or later.

---

<div class="post-metadata">

**Author:** ![KaiWei\_Han](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kaiwei_han/32/172_2.png) [@KaiWei\_Han](https://discourse.slicer.org/u/KaiWei_Han)\
**Post date:** [May 8, 2017, 3:17pm UTC](https://discourse.slicer.org/t/error-with-new-extension-elastix/278/3 "2017-05-08T15:17:15Z")

</div>

to Andras Lasso，thank you very much，problem solved.
