openslide on Apple silicon?

Jon Sauer jon.sauer at gmail.com
Tue Sep 5 07:46:57 EDT 2023


Hi,

After struggling for over a day using ‘port’ to uninstall and subsequentialy install packages revealed using 'sudo port install openslide’, it finally failed installing ‘llvm-3.5’:

--->  Found 102 broken files, matching files to ports
Warning: No port llvm-3.5 found in the index; can't rebuild
--->  Broken files found, but all associated ports are not in the index and so cannot be rebuilt.

‘pip’ also can’t install openslide.

So installed Miniconda. It seemed to install openslide OK but ‘import openslide’ fails as below: I don’t want to struggle finding another way to read .svs files, so I’m hoping there is something that can be done to make openslide operational on my Mac Studio initially cloned from an Intel MacBook Pro. ‘brew’ was reinstalled and used to install python 3.11.
# -----------------------------------------------------------------
(dl4cv) sauer : Sep_2023_dev  $ python3
Python 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import openslide
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/openslide/lowlevel.py", line 74, in _load_library
    return try_load(['libopenslide.1.dylib', 'libopenslide.0.dylib'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openslide/lowlevel.py", line 58, in try_load
    return cdll.LoadLibrary(name)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python at 3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py", line 454, in LoadLibrary
    return self._dlltype(name)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python at 3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: dlopen(libopenslide.0.dylib, 0x0006): tried: 'libopenslide.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibopenslide.0.dylib' (no such file), '/opt/homebrew/Cellar/python at 3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/../../../../../../../../../../../lib/libopenslide.0.dylib' (no such file), '/usr/lib/libopenslide.0.dylib' (no such file, not in dyld cache), 'libopenslide.0.dylib' (no such file), '/usr/local/lib/libopenslide.0.dylib' (no such file), '/usr/lib/libopenslide.0.dylib' (no such file, not in dyld cache)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.11/site-packages/openslide/__init__.py", line 31, in <module>
    from openslide import lowlevel
  File "/opt/homebrew/lib/python3.11/site-packages/openslide/lowlevel.py", line 92, in <module>
    _lib = _load_library()
           ^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/openslide/lowlevel.py", line 83, in _load_library
    raise ModuleNotFoundError(
ModuleNotFoundError: Couldn't locate OpenSlide dylib.  Is OpenSlide installed correctly?  https://openslide.org/api/python/#installing
>>>
# -----------------------------------------------------------------
Cheers,
  Jon

> On Aug 31, 2023, at 2:53 PM, Jon Sauer <jon.sauer at gmail.com> wrote:
> 
> Hi Benjamin,
> 
> Yes indeed, my whole environment on the new Mac Studio was migrated from my old 15” 2016 MacBook Pro, an x86_64 machine just as you surmised.
> 
> Many, many thanks. I’ll make the necessay changes, only mention something again if I can’t make it work.
> 
> Thanks again.
> 
> Cheers,
>   Jon
> 
> Jon.Sauer at gmail.com
> cell: +1.303.579.3009
> White River Junction, VT, USA
> 
> 
>> On Aug 31, 2023, at 12:34 PM, Benjamin Gilbert <bgilbert at cs.cmu.edu> wrote:
>> 
>> On Thu, Aug 31, 2023 at 11:32 AM Jon Sauer <jon.sauer at gmail.com> wrote:
>>> OSError: dlopen(/usr/local/lib/libopenslide.dylib, 0x0006): tried: '/usr/local/lib/libopenslide.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/libopenslide.dylib' (no such file), '/usr/local/lib/libopenslide.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/usr/local/Cellar/openslide/3.4.1_7/lib/libopenslide.0.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/Cellar/openslide/3.4.1_7/lib/libopenslide.0.dylib' (no such file), '/usr/local/Cellar/openslide/3.4.1_7/lib/libopenslide.0.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64’))
>> 
>> OpenSlide Python found your Homebrew copy of OpenSlide in /usr/local,
>> but couldn't load it because it's an x86_64 binary instead of an arm64
>> binary.  On ARM, Homebrew installs into /opt/homebrew instead.  Is it
>> possible that your Homebrew installation was migrated from a previous
>> x86_64 machine?  You might consider removing and reinstalling Homebrew
>> so you have native ARM binaries.  That should also fix the error
>> you're seeing.
>> 
>> --Benjamin Gilbert
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/openslide-users/attachments/20230905/74412bf3/attachment.html>


More information about the openslide-users mailing list