# SimpleITK install error on mac

**URL:** https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829
**Category:** Development
**Created:** [January 15, 2020, 8:32pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829 "2020-01-15T20:32:25Z")
**Posts on this page:** 12
**Page:** 1

<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: [January 15, 2020, 8:32pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/1 "2020-01-15T20:32:25Z")

</div>

I’m getting this error currently. I tried deleting all SimpleITK directories and rebuilding but I hit the same thing. When I have a chance I’ll try a completely clean build tree, but for now I’ll turn of SimpleITK in my build.

```auto
[81%] **Completed 'SimpleITK'**

[100%] Built target SimpleITK

[97%] **Performing install step for 'SimpleITK'**

-- SimpleITK: Removing 'install' log files

-- SimpleITK: SimpleITK_WORKING_DIR: /Users/pieper/slicer/latest/sbrew/SimpleITK-build/SimpleITK-build/Wrapping/Python

-- SimpleITK: /Users/pieper/slicer/latest/sbrew/python-install/bin/PythonSlicer;Packaging/setup.py;install

-- SimpleITK: Errors detected - See below.

running install

running bdist_egg

running egg_info

writing SimpleITK.egg-info/PKG-INFO

writing dependency_links to SimpleITK.egg-info/dependency_links.txt

writing top-level names to SimpleITK.egg-info/top_level.txt

reading manifest file 'SimpleITK.egg-info/SOURCES.txt'

writing manifest file 'SimpleITK.egg-info/SOURCES.txt'

installing library code to build/bdist.macosx-10.15-x86_64/egg

running install_lib

running build_py

running build_ext

copying /Users/pieper/slicer/latest/sbrew/SimpleITK-build/SimpleITK-build/Wrapping/Python/_SimpleITK.so -> build/lib.macosx-10.15-x86_64-3.6/SimpleITK/_SimpleITK.cpython-36m-darwin.so

creating build/bdist.macosx-10.15-x86_64/egg

creating build/bdist.macosx-10.15-x86_64/egg/SimpleITK

copying build/lib.macosx-10.15-x86_64-3.6/SimpleITK/SimpleITK.py -> build/bdist.macosx-10.15-x86_64/egg/SimpleITK

copying build/lib.macosx-10.15-x86_64-3.6/SimpleITK/ __init__.py -> build/bdist.macosx-10.15-x86_64/egg/SimpleITK

copying build/lib.macosx-10.15-x86_64-3.6/SimpleITK/_SimpleITK.cpython-36m-darwin.so -> build/bdist.macosx-10.15-x86_64/egg/SimpleITK

byte-compiling build/bdist.macosx-10.15-x86_64/egg/SimpleITK/SimpleITK.py to SimpleITK.cpython-36.pyc

byte-compiling build/bdist.macosx-10.15-x86_64/egg/SimpleITK/ __init__.py to __init__.cpython-36.pyc

creating stub loader for SimpleITK/_SimpleITK.cpython-36m-darwin.so

byte-compiling build/bdist.macosx-10.15-x86_64/egg/SimpleITK/_SimpleITK.py to _SimpleITK.cpython-36.pyc

installing package data to build/bdist.macosx-10.15-x86_64/egg

running install_data

copying /Users/pieper/slicer/latest/sbrew/SimpleITK/LICENSE -> build/bdist.macosx-10.15-x86_64/egg/

copying /Users/pieper/slicer/latest/sbrew/SimpleITK/NOTICE -> build/bdist.macosx-10.15-x86_64/egg/

copying /Users/pieper/slicer/latest/sbrew/SimpleITK/Readme.md -> build/bdist.macosx-10.15-x86_64/egg/

copying /Users/pieper/slicer/latest/sbrew/SimpleITK-build/SimpleITK-build/ITK-5.1-NOTICE -> build/bdist.macosx-10.15-x86_64/egg/

copying /Users/pieper/slicer/latest/sbrew/SimpleITK-build/SimpleITK-build/ITK-5.1-README.md -> build/bdist.macosx-10.15-x86_64/egg/

creating build/bdist.macosx-10.15-x86_64/egg/EGG-INFO

copying SimpleITK.egg-info/PKG-INFO -> build/bdist.macosx-10.15-x86_64/egg/EGG-INFO

copying SimpleITK.egg-info/SOURCES.txt -> build/bdist.macosx-10.15-x86_64/egg/EGG-INFO

copying SimpleITK.egg-info/dependency_links.txt -> build/bdist.macosx-10.15-x86_64/egg/EGG-INFO

copying SimpleITK.egg-info/top_level.txt -> build/bdist.macosx-10.15-x86_64/egg/EGG-INFO

writing build/bdist.macosx-10.15-x86_64/egg/EGG-INFO/native_libs.txt

creating 'dist/SimpleITK-1.3.0.dev527-py3.6-macosx-10.15-x86_64.egg' and adding 'build/bdist.macosx-10.15-x86_64/egg' to it

removing 'build/bdist.macosx-10.15-x86_64/egg' (and everything under it)

Processing SimpleITK-1.3.0.dev527-py3.6-macosx-10.15-x86_64.egg

removing '/Users/pieper/slicer/latest/sbrew/python-install/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.15-x86_64.egg' (and everything under it)

creating /Users/pieper/slicer/latest/sbrew/python-install/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.15-x86_64.egg

Extracting SimpleITK-1.3.0.dev527-py3.6-macosx-10.15-x86_64.egg to /Users/pieper/slicer/latest/sbrew/python-install/lib/python3.6/site-packages

SimpleITK 1.3.0.dev527 is already the active version in easy-install.pth

Installed /Users/pieper/slicer/latest/sbrew/python-install/lib/python3.6/site-packages/SimpleITK-1.3.0.dev527-py3.6-macosx-10.15-x86_64.egg

Processing dependencies for SimpleITK==1.3.0.dev527

Searching for SimpleITK==1.3.0.dev527

Reading https://pypi.org/simple/SimpleITK/

zip_safe flag not set; analyzing archive contents...

SimpleITK. __pycache__.SimpleITK.cpython-36: module references __file__

SimpleITK. __pycache__._SimpleITK.cpython-36: module references __file__

No local packages or working download links found for SimpleITK==1.3.0.dev527

error: Could not find suitable distribution for Requirement.parse('SimpleITK==1.3.0.dev527')

CMake Error at /Users/pieper/slicer/latest/Slicer/CMake/ExternalProjectForNonCMakeProject.cmake:104 (message):

SimpleITK: install step failed with exit code '1'.

Outputs also captured in

/Users/pieper/slicer/latest/sbrew/SimpleITK_install_step_output.txt and

/Users/pieper/slicer/latest/sbrew/SimpleITK_install_step_error.txt.

Setting env. variable EP_EXECUTE_DISABLE_CAPTURE_OUTPUTS to 1 allows to

disable file capture.

Call Stack (most recent call first):

/Users/pieper/slicer/latest/sbrew/SimpleITK_install_step.cmake:3 (ExternalProject_Execute)

make[3]: *** [SimpleITK-prefix/src/SimpleITK-stamp/SimpleITK-install] Error 1

make[2]: *** [CMakeFiles/SimpleITK.dir/all] Error 2

make[1]: *** [CMakeFiles/SimpleITK.dir/rule] Error 2

make: *** [SimpleITK] Error 2

rock:sbrew pieper$

```

---

<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: [January 15, 2020, 9:06pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/2 "2020-01-15T21:06:18Z")

</div>

There is a good chance that you could not properly clean your python site packages folders manually and that’s why it cannot find SimpleITK, so it would help if you could test with a clean build.

Clean build looks successful on the dashboard ([http://slicer.cdash.org/index.php?project=SlicerPreview](http://slicer.cdash.org/index.php?project=SlicerPreview)) but sitkUtils test fail.

@jcfr @Sam_Horvath @jamesobutler Are you going to have time to look into this SimpleITK Mac issue? If not then maybe we should revert the ITK/SimpleITK update for now until someone has time to investigate.

---

<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: [January 16, 2020, 12:34am UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/3 "2020-01-16T00:34:12Z")

</div>

Sorry I don’t have access to a Mac right now to debug these Mac specific issues.

---

<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: [January 16, 2020, 3:39pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/4 "2020-01-16T15:39:52Z")

</div>

Deleting all SimpleITK and all [pP]ython\* directories in the superbuild tree worked.

When I try to run a the MRHead through the MedianImageFilter I get this error in my local build, but the same operation work in the preview build of 2020-01-08.

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

---

<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: [January 16, 2020, 4:30pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/5 "2020-01-16T16:30:59Z")

</div>

@blowekamp do you have any clue what could have changed in ITK and SimpleITK to cause this problem? See change log [here](https://github.com/Slicer/Slicer/commit/15fda09332c42bf185958ffbc14c9c18b7715a5a).

---

<div class="post-metadata">

### Author: ![blowekamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/blowekamp/32/1386_2.png) [@blowekamp](https://discourse.slicer.org/u/blowekamp)
#### Post date: [January 16, 2020, 6:05pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/6 "2020-01-16T18:05:11Z")

</div>

Hello,

This error looks likely to be caused by the OSX peculiarities to `dynamic_cast` requirements to have the symbol be from the same compilation unit. The old OSX SDKs don’t have this behavior, so that is likely the difference between Steve’s and the preview build. This is not an issue for SimpleITK’s binary distribution but is a problem with it integrated into Slicer with all the duplicate ITK symbols from different libraries floating around.

I suspect that it was this commit which changed the behavior is Slicer:

> <https://github.com/SimpleITK/SimpleITK/commit/ddde6bf0d262877ed3d822d160463f47d952c088>

Two things which may help the situation are:

- set `SimpleITK_EXPLICIT_INSTANTIATION=ON` for OSX in the Superbuild.
- Using setting SimpleITK to use static libraries. This will ensure all SimpleITK’s symbols are consistent, but would likely ensure dynamic\_cast failures if the C++ API was used.

---

<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: [January 16, 2020, 6:34pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/7 "2020-01-16T18:34:07Z")

</div>

@blowekamp thanks a lot for the quick and helpful response.

> [@blowekamp](#):
>
> This is not an issue for SimpleITK’s binary distribution but is a problem with it integrated into Slicer with all the duplicate ITK symbols from different libraries floating around

@jcfr worked on removing all ITK symbol duplications in Slicer binaries for several years. It is terrible to hear that there are still problems around this.

> [@blowekamp](#):
>
> - set `SimpleITK_EXPLICIT_INSTANTIATION=ON` for OSX in the Superbuild.
> - Using setting SimpleITK to use static libraries. This will ensure all SimpleITK’s symbols are consistent, but would likely ensure dynamic\_cast failures if the C++ API was used.

We use the plain ITK API for C++ API. Can we just enable SimpleITK\_EXPLICIT\_INSTANTIATION or there would be other consequences?

---

<div class="post-metadata">

### Author: ![blowekamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/blowekamp/32/1386_2.png) [@blowekamp](https://discourse.slicer.org/u/blowekamp)
#### Post date: [January 16, 2020, 6:48pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/8 "2020-01-16T18:48:12Z")

</div>

The logic in the above commit in SimpleITK may need to be updated to automatically turn on SimpleITK\_EXPLICIT\_INSTANTIATION when shared libraries are enabled. I’ll have to do some testing.

It would be best if Slicer always explicitly enabled the above flag, as that is the way which has been working for Slicer.

---

<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: [January 16, 2020, 7:14pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/9 "2020-01-16T19:14:11Z")

</div>

> [@blowekamp](#):
>
> It would be best if Slicer always explicitly enabled the above flag, as that is the way which has been working for Slicer.

Thank you, I’ll enable this option then and we’ll see in tomorrow’s build if it indeed fixes the issue.

---

<div class="post-metadata">

### Author: ![blowekamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/blowekamp/32/1386_2.png) [@blowekamp](https://discourse.slicer.org/u/blowekamp)
#### Post date: [January 16, 2020, 7:26pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/10 "2020-01-16T19:26:45Z")

</div>

> [@lassoan](#):
>
> Thank you, I’ll enable this option then and we’ll see in tomorrow’s build if it indeed fixes the issue.

But Steve said:

> [@pieper](#):
>
> When I try to run a the MRHead through the MedianImageFilter I get this error in my local build, but the same operation work in the preview build of 2020-01-08.

So it’s OK with the preview builds, but not local builds compiled against a newer OSX SDK.

---

<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: [January 16, 2020, 7:34pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/11 "2020-01-16T19:34:57Z")

</div>

Confirmed, running this and rebuilding fixed the problem.

```auto
(cd SimpleITK-build/; cmake -D SimpleITK_EXPLICIT_INSTANTIATION:BOOL=ON .)

```

Any downsides to just adding that to the superbuild script?

---

<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: [January 16, 2020, 9:47pm UTC](https://discourse.slicer.org/t/simpleitk-install-error-on-mac/9829/12 "2020-01-16T21:47:26Z")

</div>

I’ve added SimpleITK\_EXPLICIT\_INSTANTIATION:BOOL=ON to the superbuild script ([https://github.com/Slicer/Slicer/commit/506754f1becd5df717464e320c154142ccd701cb](https://github.com/Slicer/Slicer/commit/506754f1becd5df717464e320c154142ccd701cb)  
).
