Changes between Version 1 and Version 2 of Ticket #63492


Ignore:
Timestamp:
Sep 15, 2021, 5:13:35 PM (3 years ago)
Author:
ryandesign (Ryan Carsten Schmidt)
Comment:

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.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #63492

    • Property Status changed from new to assigned
    • Property Summary changed from openslide @3.4.1_1 (active) py37-openslide @1.1.2_1 (active) Using python3.7. to py37-openslide @1.1.2_1: OSError: dlopen(libopenslide.0.dylib, 6): image not found
    • Property Priority changed from High to Normal
    • Property Owner set to bgilbert
    • Property Port py-openslide added; py37-openslide removed
  • Ticket #63492 – Description

    v1 v2  
    11virtual environment created with
     2{{{
    23conda create -n openslide_bug python=3.7
     4}}}
    35
    46python command import openslide fails
     
    68Attaching files with descriptive names
    79
    8 MacBook Pro (Retina, 15-inch, Mid 2015)
     10MacBook Pro (Retina, 15-inch, Mid 2015)\\
    911Macos 11.5.2