The error shown in the first attached file is:
OSError: dlopen(libopenslide.0.dylib, 6): image not found
Does /opt/local/lib/libopenslide.0.dylib exist? If so, what's the output of otool -L /opt/local/lib/libopenslide.0.dylib
? What I'm looking for is whether the second line of output lists the full library path as it should (/opt/local/lib/libopenslide.0.dylib) or just its name (libopenslide.0.dylib). Our binary packages of openslide look like they have the correct full library path.
dlopen probably needs a full path to the library file to work, but the error message only listed the library name. Looking closer at the error message, I see that the problem is probably here:
File "/Users/dbae/opt/anaconda3/envs/openslide_bug/lib/python3.7/site-packages/openslide/lowlevel.py", line 46, in <module>
_lib = cdll.LoadLibrary('libopenslide.0.dylib')
Looks like py-openslide's code explicitly calls cdll.LoadLibrary('libopenslide.0.dylib')
. Presumably that will need to be changed to use the absolute library path, i.e. cdll.LoadLibrary('/opt/local/lib/libopenslide.0.dylib')
.
The code in lowlevel.py reads:
elif platform.system() == 'Darwin':
try:
_lib = cdll.LoadLibrary('libopenslide.0.dylib')
except OSError:
# MacPorts doesn't add itself to the dyld search path, but
# does add itself to the find_library() search path
# (DEFAULT_LIBRARY_FALLBACK in ctypes.macholib.dyld) on
# Python 2.6 and 2.7. Python 3 users on MacPorts should add
# the MacPorts lib directory to DYLD_LIBRARY_PATH.
import ctypes.util
_lib = ctypes.util.find_library('openslide')
if _lib is None:
raise ImportError("Couldn't locate OpenSlide dylib. " +
"Is OpenSlide installed?")
_lib = cdll.LoadLibrary(_lib)
The advice in those comments seems terrible to me: users should most certainly not add the MacPorts lib directory to DYLD_LIBRARY_PATH; that will break immense numbers of things. The developers of py-openslide should fix their software so that that's not necessary.