dkazanc / TomoPhantom

Software to generate 2D/3D/4D analytical phantoms and their Radon transforms (parallel beam) for image processing
https://dkazanc.github.io/TomoPhantom/
Apache License 2.0
116 stars 53 forks source link

Misleading error with old glibc #120

Closed samtygier-stfc closed 1 month ago

samtygier-stfc commented 1 month ago

I spotted this while setting up an environment on a Rocky8 vm.

When importing tomophantom I get the error

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/sjd54579/miniforge3/envs/tp/lib/python3.11/site-packages/tomophantom/__init__.py", line 2, in <module>
    from tomophantom.TomoP2D import *
  File "/home/sjd54579/miniforge3/envs/tp/lib/python3.11/site-packages/tomophantom/TomoP2D.py", line 28, in <module>
    import tomophantom.ctypes.external as external
  File "/home/sjd54579/miniforge3/envs/tp/lib/python3.11/site-packages/tomophantom/ctypes/external.py", line 36, in <module>
    LIB_TOMOPHANTOM = c_shared_lib("tomophantom")
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sjd54579/miniforge3/envs/tp/lib/python3.11/site-packages/tomophantom/ctypes/__init__.py", line 44, in c_shared_lib
    raise ModuleNotFoundError(
ModuleNotFoundError: TomoPhantom links to compiled components which are installed separately and loaded using ctypes.util.find_library(). A required library, tomophantom, was not found.

I can see the real error message by doing:

python -c "import ctypes, ctypes.util; ctypes.cdll.LoadLibrary(ctypes.util.find_library('tomophantom'))"

I get

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/sjd54579/miniforge3/envs/tp/lib/python3.11/ctypes/__init__.py", line 454, in LoadLibrary
    return self._dlltype(name)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/sjd54579/miniforge3/envs/tp/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /home/sjd54579/miniforge3/envs/tp/lib/libtomophantom.so)

Steps to reproduce on Rocky 8

conda create -n tp -c httomo tomophantom
conda activate tp
python -c "import tomophantom"
python -c "import ctypes, ctypes.util; ctypes.cdll.LoadLibrary(ctypes.util.find_library('tomophantom'))"

I am not sure how easy it would be to get a build that runs on older glibc versions, but it would save some confusion to see the full error message.

dkazanc commented 1 month ago

Thanks @samtygier-stfc. As I remember, I built the library using Ubuntu 22.04, which is slightly newer compared to Rocky 8. So I guess the GLIBC error can be explained by that. I'll try to re-compile the library using RH8. Actually, I don't know why I haven't set up a CI Action job to do that...

dkazanc commented 1 month ago

@samtygier-stfc can you please try now with the version 3.0.1? It could be the same issue but I've used Github CI this time and ubuntu 22. For some reason it wasn't building correctly for ubuntu 20.

samtygier-stfc commented 1 month ago

I get exactly the same with tomophantom 3.0.1 pyh2b07374_0 httomo

dkazanc commented 1 month ago

Ok, I've re-built on RH8, can you please try 3.0.1 again. May be also trying the newer pyh4f56d60_0, but I guess the other version should be fine if it picks up the updated library file. Cheers.

dkazanc commented 1 month ago

Does it fix the problem @samtygier-stfc ?

samtygier-stfc commented 1 month ago

Thanks. Yes that works on rocky8 with pyh4f56d60_0.