Opened 3 years ago

Last modified 3 years ago

#63492 closed defect

py37-openslide @1.1.2_1: OSError: dlopen(libopenslide.0.dylib, 6): image not found — at Version 2

Reported by: DavidBAEpstein Owned by: bgilbert (Benjamin Gilbert)
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: Cc:
Port: openslide, py-openslide

Description (last modified by ryandesign (Ryan Carsten Schmidt))

virtual environment created with

conda create -n openslide_bug python=3.7

python command import openslide fails

Attaching files with descriptive names

MacBook Pro (Retina, 15-inch, Mid 2015)
Macos 11.5.2

Change History (5)

Changed 3 years ago by DavidBAEpstein

Attachment: buggy.py_with_output added

Changed 3 years ago by DavidBAEpstein

Attachment: port_installed added

Changed 3 years ago by DavidBAEpstein

Attachment: conda_list added

comment:1 Changed 3 years ago by DavidBAEpstein

Description: modified (diff)

comment:2 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Owner: set to bgilbert
Port: py-openslide added; py37-openslide removed
Priority: HighNormal
Status: newassigned
Summary: openslide @3.4.1_1 (active) py37-openslide @1.1.2_1 (active) Using python3.7.py37-openslide @1.1.2_1: OSError: dlopen(libopenslide.0.dylib, 6): image not found

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.

Note: See TracTickets for help on using tickets.