I’ve been getting this error for a while on mac. This is from the latest nightly. Please let me know if you’d like me to report it on the issue tracker.
Python 3.6.7 (default, Jun 23 2019, 23:06:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
>>> import SimpleITK
Traceback (most recent call last):
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK/SimpleITK.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: dlopen(/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK/_SimpleITK.cpython-36m-darwin.so, 1): Library not loaded: /Volumes/Dashboards/Preview/Slicer-0-build/ITK-build/lib/libITKIOBruker-5.0.1.dylib
Referenced from: /Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK/_SimpleITK.cpython-36m-darwin.so
Reason: image not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK/__init__.py", line 1, in <module>
from .SimpleITK import *
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK/SimpleITK.py", line 21, in <module>
_SimpleITK = swig_import_helper()
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK/SimpleITK.py", line 20, in swig_import_helper
return importlib.import_module('_SimpleITK')
File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_SimpleITK'
>>>
I can replicate your issue on mac with the nightly. The key message seems to be missing libITKIOBruker-5.0.1.dylib.
@blowekamp is coming to project week and hopefully we can look through this together. It seems it’s something to do with the way SimpleITK interacts with remote ITK modules with image IO functions.
This indicate that when when the SimpleITK library is being loaded the linker can not find the libITKIOBruker-5.0.1.dylib dependency. The things to check are:
Does libITKIOBruker-5.0.1.dylib exist in the proper place in the Mac Bundle?
Run otool -L on _SimpleITK.so to verify that it has been fixed up correctly.
Unfortunately, I seem to be having trouble getting to www.slicer.org right now to download the latest nightly. I’ll be at project week on Thursday.
Thanks @blowekamp - slicer.org seems to be working now for me if you want to have a look.
When we looked before it seems the Bruker reader is not being included or fixed up, maybe as part of the SimpleITK build step. Do you know if that’s something that’s changed recently? It works in Slicer 4.10.2 but that’s an older ITK. We can look at it when you are at Project Week.
And the SimpleITK library is not being fixed up at all:
$otool -L Slicer-4.11.0-2019-06-24.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK/_SimpleITK.cpython-36m-darwin.so
Slicer-4.11.0-2019-06-24.app/Contents/lib/Python/lib/python3.6/site-packages/SimpleITK/_SimpleITK.cpython-36m-darwin.so:
/Volumes/Dashboards/Preview/Slicer-0-build/ITK-build/lib/libITKIOBruker-5.0.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Volumes/Dashboards/Preview/Slicer-0-build/ITK-build/lib/libITKIODCMTK-5.0.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Volumes/Dashboards/Preview/Slicer-0-build/ITK-build/lib/libITKIOHDF5-5.0.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Volumes/Dashboards/Preview/Slicer-0-build/ITK-build/lib/libITKIOJPEG2000-5.0.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Volumes/Dashboards/Preview/Slicer-0-build/ITK-build/lib/libITKIOLSM-5.0.1.dylib (compatibility version 1.0.0, current version 1.0.0)
I think SimpleITK from pip install is v1.2.0 which is built using ITK v4.13 even though it is ITKv5 compatible. Probably not the best since Slicer is using ITKv5
Check with
import SimpleITK as sitk
sitk.Version().ITKVersionString()
I thought I asked a question along those lines to JC at the project week, and I thought the response was that packages installed via pip are installed into separate directory, along with their dependencies, so they would not conflict with any packages already installed. I guess I misunderstood the answer. I thought SimpleITK will use ITK it will bring along, and will not conflict with Slicer ITK 5.
WARNING: In C:\d\VS14-Win64-pkg\SimpleITK-build\ITK\Modules\Core\Common\src\itkObjectFactoryBase.cxx, line 664
Possible incompatible factory load:
Running itk version :
itk version 4.13.1
Loaded factory version:
itk version 5.0.0
Loading factory:
C:/Users/JamesButler/AppData/Local/NA-MIC/Slicer 4.11.0-2019-06-23/bin/../lib/Slicer-4.11/ITKFactories\MRMLIDIOPlugin.dll
As I understood from @jcfr, ITK Puthon is built statically, so there is no version conflict except the IO factory. Unfortunately, ABI incompatibility in the IO factory can break everything.
I guess SimpleITK will upgrade to the latest stable ITK version (5.x) at some point, which may happen more quickly if we ask for it.