tlambert03 / nd2

Full-featured nd2 (Nikon NIS Elements) file reader for python. Outputs to numpy, dask, and xarray. Exhaustive metadata extraction
https://tlambert03.github.io/nd2
BSD 3-Clause "New" or "Revised" License
54 stars 15 forks source link

ImportError: libnd2readsdk-shared.so: cannot open shared object file (CentOS) #16

Closed gioelelm closed 2 years ago

gioelelm commented 3 years ago

Description

I was trying to use the library for the first time to open a .nd2 files. I got an error that seems to show that the ND2SDK is somehow not correctly installed. I downloaded it, got it installed by rpm -i nd2readsdk-static-1.7.2.0-Linux.rpm but the problem persisted.

Any insight on how this could be solved?

What I Did

import nd2
import numpy as np

my_array = nd2.imread('myfile.nd2') 

and got

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-4b821c59f310> in <module>
      2 import numpy as np
      3 
----> 4 my_array = nd2.imread('myfile.nd2')

~/anaconda3/envs/newly/lib/python3.8/site-packages/nd2/nd2file.py in imread(file, dask, xarray)
    440 
    441 def imread(file: str, dask: bool = False, xarray: bool = False):
--> 442     with ND2File(file) as nd2:
    443         if xarray:
    444             return nd2.to_xarray(delayed=dask)

~/anaconda3/envs/newly/lib/python3.8/site-packages/nd2/nd2file.py in __init__(self, path)
     40     def __init__(self, path: Union[Path, str]) -> None:
     41         self._path = str(path)
---> 42         self._rdr = get_reader(self._path)
     43         self._closed = False
     44         self._is_legacy = "Legacy" in type(self._rdr).__name__

~/anaconda3/envs/newly/lib/python3.8/site-packages/nd2/_util.py in get_reader(path)
     22         magic_num = fh.read(4)
     23         if magic_num == NEW_HEADER_MAGIC:
---> 24             from ._sdk.latest import ND2Reader
     25 
     26             return ND2Reader(path)

~/anaconda3/envs/newly/lib/python3.8/site-packages/nd2/_sdk/__init__.py in <module>
----> 1 from . import latest
      2 
      3 __all__ = ["latest"]

ImportError: libnd2readsdk-shared.so: cannot open shared object file: No such file or directory
tlambert03 commented 3 years ago

have you tried pip install nd2 ?

gioelelm commented 3 years ago

Yes, I did, that's the first thing I tried (second actually, the first was trying the installation of aicsimageio where I got the same error)

tlambert03 commented 3 years ago

hmm, ok, this must be a CentOS thing... I'm afraid I'll probably have to create a new/special distribution for that. In the meantime, I'll try to make it easier for you to build locally using the SDK that you've downloaded. Thanks for letting me know

gioelelm commented 3 years ago

Thank you very much for this!

tlambert03 commented 2 years ago

hey @gioelelm, nd2 is now building on centos7 on conda forge, so I'm hoping this will work for you. Can you confirm? conda install -c conda-forge nd2