ImportError: Couldn't locate OpenSlide dylib. Is OpenSlide installed?

3.8k Views Asked by At

Context

Issue type : import error
Operating system : Mac OS 10.14.5
OpenSlide Python version : openslide-python 1.1.1

Details

hi, I have installed openslide-python 1.1.1 on Mac OS 10.14.5 (in a virtualenv environment) with the command :

pip install openslide-python

I am facing this error when typing import openslide in a python shell :

Traceback (most recent call last):
  File ".../lib/python3.6/site-packages/openslide/lowlevel.py", line 44, in <module>
    _lib = cdll.LoadLibrary('libopenslide.0.dylib')
  File "/anaconda3/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "/anaconda3/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libopenslide.0.dylib, 6): image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python3.6/site-packages/openslide/__init__.py", line 29, in <module>
    from openslide import lowlevel
  File ".../lib/python3.6/site-packages/openslide/lowlevel.py", line 55, in <module>
    "Is OpenSlide installed?")
ImportError: Couldn't locate OpenSlide dylib.  Is OpenSlide installed?

I went to the GitHub rep. of openslide-python but I could'nt find any decent answer to this issue...

If anyone has an answer, it would be amazing.
Thanks

2

There are 2 best solutions below

2
On

@Cao Minh Vu solved this issue :

to use openslide-python on a Mac, you need to install openslide first.
to do so, type brew install openslide in a command shell (if you don't have homebrew installed, install it, it is quick and easy).
once openslide is installed, you can type pip install openslide-python in a command shell.

eventually, import openslide will work!!

0
On

simply just run conda install -c conda-forge openslide if you are using anaconda it will solve the issue.