>>> import otbApplication
----> 1 import otbApplication
2
3 from image_utils import get_filename
~/Documents/OTB-5.8.0-Darwin64/lib/python/otbApplication.py in <module>()
26 fp.close()
27 return _mod
---> 28 _otbApplication = swig_import_helper()
29 del swig_import_helper
30 else:
~/Documents/OTB-5.8.0-Darwin64/lib/python/otbApplication.py in swig_import_helper()
22 if fp is not None:
23 try:
---> 24 _mod = imp.load_module('_otbApplication', fp, pathname, description)
25 finally:
26 fp.close()
ImportError: dlopen(~/Documents/OTB-5.8.0-Darwin64/lib/python/_otbApplication.so, 2): Library not loaded: @rpath/libOTBApplicationEngine-5.8.1.dylib
Referenced from: ~/Documents/OTB-5.8.0-Darwin64/lib/python/_otbApplication.so
Reason: image not found
Checking the dependencies, we see
otool -L _otbApplication.so
_otbApplication.so:
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.6)
@rpath/libOTBApplicationEngine-5.8.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@rpath/libOTBImageIO-5.8.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@rpath/libOTBIORAD-5.8.1.dylib (compatibility version 1.0.0, current version 1.0.0)
...
A solution to the problem is to use install_name_tool
install_name_tool -change @rpath/libOTBApplicationEngine-5.8.1.dylib path/to/OTB/lib/libOTBApplicationEngine-5.8.1.dylib _otbApplication.so
and in a batch mode :
cd /path/to/OTB-5.8.0
otool -L lib/python/_otbApplication.so | grep -ohe "@rpath/\(\S\)*" | grep -ohe "lib\(\S\)*" | while read i; do install_name_tool -change @rpath/$i $PWD/lib/$i lib/python/_otbApplication.so; done
Bonus If you use python from brew and not a system one, you will need to change
/System/Library/Frameworks/Python.framework/Versions/2.7/Python
by the following command:
install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/Python _otbApplication.so
Thanks for this fix !
Would it work if you replace
@rpath/
with@rpath/../
in _otbApplication.so dependencies ?