5

I am trying to use openslide's python bindings (http://openslide.org/download/) and have tried just about everything with no success in being able to import openslide to Python 2.7. Here's my error message:

    >>> import openslide
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/local/lib/python2.7/site-packages/openslide/__init__.py", line 29, in <module>
    from openslide import lowlevel
    File "/usr/local/lib/python2.7/site-packages/openslide/lowlevel.py", line 52, in <module>
    raise ImportError("Couldn't locate OpenSlide library")
    ImportError: Couldn't locate OpenSlide library

I have pip install openslide-python successfully, and it seems like it is being recognized by the recognition of line 29 and 52 in packages/openslide.

Any suggestions on how to proceed?

4

2 回答 2

2

您需要安装 openslide 库和依赖项,然后是 python 包。在此处阅读有关您的操作系统的说明:

http://openslide.org/download/

于 2016-07-26T18:06:53.763 回答
0

这被称为“DLL 地狱”。在此源代码中,有一个 Windows DLL 文件优先于 python 需要的 DLL 文件。在使用 C openslide 库 DLL 文件所在的 bin 文件夹的完整路径调用 C openslide 库之前,您需要在 Python 绑定模块中添加 PATH 变量。这将使用 OpenSlide“zlib1.dll”文件覆盖 Windows“zlib1.dll”文件。

import os
openslide_path = os.getcwd() + "\\openslide-win64-20171122\\bin"
os.environ['PATH'] = openslide_path + ";" + os.environ['PATH']
from openslide import OpenSlide

openslide_path 指示的路径可以在这里下载。这是 OpenSlide C 库。

https://openslide.org/download/

您还需要在您的 python 环境中安装“openslide-python”包。

于 2020-10-02T17:49:20.497 回答