Mouse-Imaging-Centre / pyminc

A python interface to the MINC 2 library, allowing use of numpy arrays to access MINC data, and other such similar goodies, developed by Jason Lerch
http://en.wikibooks.org/wiki/MINC/Tutorials
Other
14 stars 8 forks source link

Error when importing pyminc #39

Closed koegl closed 2 years ago

koegl commented 3 years ago

When running this line (as shown in the example) from pyminc.volumes.factory import *

I get the following error:

Something went wrong loading shared libraries ...Traceback (most recent call last):
  File "/home/fryderyk/Desktop/venvs/mthesis/lib/python3.6/site-packages/pyminc/volumes/libpyminc2.py", line 14, in <module>
    libminc = cdll.LoadLibrary("libminc2.dylib")
  File "/usr/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libminc2.dylib: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fryderyk/PycharmProjects/pythonProject/main.py", line 1, in <module>
    from pyminc.volumes.factory import *
  File "/home/fryderyk/Desktop/venvs/mthesis/lib/python3.6/site-packages/pyminc/volumes/factory.py", line 3, in <module>
    from .volumes import mincException, mincVolume, getDtype, transform_xyz_coordinates_using_xfm, transform_multiple_xyz_coordinates_using_xfm
  File "/home/fryderyk/Desktop/venvs/mthesis/lib/python3.6/site-packages/pyminc/volumes/volumes.py", line 1, in <module>
    from .libpyminc2 import *
  File "/home/fryderyk/Desktop/venvs/mthesis/lib/python3.6/site-packages/pyminc/volumes/libpyminc2.py", line 17, in <module>
    libminc = cdll.LoadLibrary("libminc2.so")
  File "/usr/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libminc2.so: cannot open shared object file: No such file or directory

I am using Ubuntu 18.04 running in a virtual box Python 3.6.9 I installed pyminc with pip3 install pyminc

Thanks for your help in advance

gdevenyi commented 3 years ago

OSError: libminc2.dylib: cannot open shared object file: No such file or directory

You do not have minc-toolkit-v2 installed and properly configuring by sourcing its config file.

bcdarwin commented 3 years ago

Closing for now as @gdevenyi's solution is almost certainly correct in this instance.

koegl commented 3 years ago

Thanks for your answer. But could you help me set it up correctly then? Becaue when I source the .sh file with . /opt/minc/1.9.18/minc-toolkit-config.sh all the commands like 'register', 'mincinfo' etc. work

gdevenyi commented 3 years ago

Please provide a complete reproducible example of all steps you take and what is happening then.

bcdarwin commented 3 years ago

Also, after sourcing the MINC toolkit command, what is the value of $LD_LIBRARY_PATH and does libminc2.so exist in that path? If not, maybe you've compiled the MINC toolkit without shared libraries?

koegl commented 3 years ago

Also, after sourcing the MINC toolkit command, what is the value of $LD_LIBRARY_PATH and does libminc2.so exist in that path? If not, maybe you've compiled the MINC toolkit without shared libraries?

echo $LD_LIBRARY_PATH returns this: /opt/minc/1.9.18/lib:/opt/minc/1.9.18/lib/InsightToolkit and the path to libminc2.so is: /opt/minc/1.9.18/lib/libminc2.so

bcdarwin commented 3 years ago

Could you run both

$ ldd /opt/minc/1.9.18/lib/libminc2.so

and

$ python3 -c 'from ctypes import cdll; cdll.LoadLibrary("/opt/minc/1.9.18/lib/libminc2.so")'

and post any output? Thanks.