openslide-python
openslide-python copied to clipboard
Windows cdll.LoadLibrary('libopenslide-0.dll') OSError: [WinError 127] The specified procedure could not be found
Context
Issue type (bug report or feature request): bug report
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): Windows 10
Platform (e.g. 64-bit x86, 32-bit ARM): x86_64
OpenSlide Python version (openslide.__version__): 1.1.1
OpenSlide version (openslide.__library_version__): 3.4.1
Slide format (e.g. SVS, NDPI, MRXS): SVS
Details
I get the following error even though OpenSlide windows binary /bin is in my PATH.
>>> import openslide
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\jxu\AppData\Roaming\Python\Python36\site-packages\openslide\__init__.py", line 29, in <module>
from openslide import lowlevel
File "C:\Users\jxu\AppData\Roaming\Python\Python36\site-packages\openslide\lowlevel.py", line 41, in <module>
_lib = cdll.LoadLibrary('libopenslide-0.dll')
File "C:\Program Files\Python36\lib\ctypes\__init__.py", line 426, in LoadLibrary
return self._dlltype(name)
File "C:\Program Files\Python36\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 127] The specified procedure could not be found
Maybe I misunderstood what "system search path" is. From https://docs.python.org/3/library/ctypes.html#finding-shared-libraries
On Windows,
find_library()searches along the system search path
The only thing that works is running python interpreter from /bin folder. https://openslide-users.andrew.cmu.narkive.com/uwZnTDGx/winerror-127-the-specified-procedure-could-not-be-found
Not the same as https://github.com/openslide/openslide-winbuild/issues/18 since this issue is error 127 and "procedure"
I had a similar issue, where ctypes gave an error stating that the module could not be located, and I found a way around it, but for that I needed to edit openslide/lowlevel.py. I replaced line 41, which currently is _lib = cdll.LoadLibrary('libopenslide-0.dll') with _lib = cdll.LoadLibrary(ctypes.util.find_library("libopenslide-0.dll")), for which I needed to add import ctypes.util as well. Also something important, the path to the openslide binaries needs to be added to PATH. One caveat: on my system all of this ran after I moved the openslide binaries folder to Program Files and then added the path to them to PATH.
Update: After openslide-python version 1.1.2 I noticed that the errror is now at line 43. If the aforementioned fix is not enough, try with from ctypes.uitl import find_library; _lib = cdll.LoadLibrary(find_library("libopenslide-0.dll"))
Issue is still present when using pip install - will this make it into release?
Now issue is
ModuleNotFoundError: No module named 'ctypes.uitl'
my issue became is ImportError: attempted relative import with no known parent package
This should be fixed by https://github.com/openslide/openslide-winbuild/pull/81.