3

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

clems
  • 129
  • 2
  • 8
  • Have you installed openslide before installing py-openslide? Step 1: Install openslide (https://openslide.org/download/) Step 2: pip install openslide-python – Cao Minh Vu Sep 09 '19 at 12:09
  • i went to openslide.org/download, dowloaded the 3.4.1 2015-04-20 tar.gz source file, followed the readme for installation but got an error while running './configure' : `error: cannot find libjpeg` – clems Sep 09 '19 at 12:35
  • Please do not download the tar.gz file, you can install by this command: brew install openslide – Cao Minh Vu Sep 09 '19 at 12:36
  • I installed homebrew, then installed openselide, and it solved the problem, thank you!! I had been looking for an answer on the GitHub rep. of openslide python for days when it was that easy... – clems Sep 09 '19 at 12:56

2 Answers2

4

@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!!

clems
  • 129
  • 2
  • 8
  • Thanks for your advice! – Weimin Wang Apr 24 '20 at 15:26
  • didn't work for me, I installed `openslide` via homebrew as part of the `vips`, then install conda environment and then (inside that environment did `pip install openslide-python`) -- no luck – Simon Mar 22 '23 at 22:02
1

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