dmpelt / foam_ct_phantom

A Python package for generating foam-like phantoms for CT.
MIT License
18 stars 5 forks source link

ImportError #9

Closed jiayangshi closed 2 years ago

jiayangshi commented 2 years ago

foam_ct_phantom is installed with given instructionconda install -c conda-forge foam_ct_phantom. And import foam_ct_phantom would give the error out.

File "/home/shij3/DDCT/01_generate_projections_phantom.py", line 1, in <module>
    import foam_ct_phantom
  File "/home/shij3/anaconda3/envs/ddct/lib/python3.9/site-packages/foam_ct_phantom/__init__.py", line 14, in <module>
    from .phantom import FoamPhantom, Phantom, MovingFoamPhantom, InfiltrationFoamPhantom, ExpandingFoamPhantom
  File "/home/shij3/anaconda3/envs/ddct/lib/python3.9/site-packages/foam_ct_phantom/phantom.py", line 13, in <module>
    from . import generate, infiltrate, project, verticalmovement, expand
  File "/home/shij3/anaconda3/envs/ddct/lib/python3.9/site-packages/foam_ct_phantom/generate.py", line 16, in <module>
    import h5py
  File "/home/shij3/anaconda3/envs/ddct/lib/python3.9/site-packages/h5py/__init__.py", line 33, in <module>
    from . import version
  File "/home/shij3/anaconda3/envs/ddct/lib/python3.9/site-packages/h5py/version.py", line 15, in <module>
    from . import h5 as _h5
  File "h5py/h5.pyx", line 1, in init h5py.h5
ImportError: /home/shij3/anaconda3/envs/ddct/lib/python3.9/site-packages/h5py/defs.cpython-39-x86_64-linux-gnu.so: undefined symbol: H5Pset_fapl_ros3

The h5py installed with foam_ct_phantom is

# Name                    Version                   Build  Channel
h5py                      3.3.0           nompi_py39h98ba4bc_100    conda-forge

If I install the h5py with conda install -c anaconda h5py, then the import error will be fixed.

# Name                    Version                   Build  Channel
h5py                      3.6.0            py39ha0f2276_0  
dmpelt commented 2 years ago

Can you try to install in a clean environment? I.e. creating a new empty conda environment and run conda install -c conda-forge foam_ct_phantom inside it? Looking at the error messages, it could be that some existing package in your current environment is expected a specific h5py package which might be causing problems...

jiayangshi commented 2 years ago

Yes, you are right. When I installed a clean environment, the problem doesn't exist. And the h5py comes with foam_ct_phantom is indeed version=3.6.0. It must be other packages in my environment that downgraded the h5py.

# Name                    Version                   Build  Channel
h5py                      3.6.0           nompi_py39h7e08c79_100    conda-forge

Sorry for false alarm.