TomographicImaging / CIL

A versatile python framework for tomographic imaging
https://tomographicimaging.github.io/CIL/
Apache License 2.0
97 stars 45 forks source link

import cil.recon failed #1864

Closed Cosme-liu closed 4 months ago

Cosme-liu commented 4 months ago

Description

when trying to import cil.recon, something went wrong:

import cil.recon

Error:
File D:\anaconda3\envs\cil\lib\ctypes\__init__.py:364, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    362 import nt
    363 mode = nt._LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
--> 364 if '/' in name or '\\' in name:
    365     self._name = nt._getfullpathname(self._name)
    366     mode |= nt._LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR

TypeError: argument of type 'NoneType' is not iterable

Environment

I installed cil package using:

mamba install -c conda-forge -c intel -c ccpi cil=23.0.1 astra-toolbox ccpi-regulariser "ipywidgets<8"

(according to the issue #1482 ) However, the installed version is:

# Name                    Version                   Build  Channel
cil                       22.1.0              np122py39_0    ccpi
paskino commented 4 months ago

Hi @Cosme-liu

What version of conda/mamba do you have?

You are trying to install an older version of CIL. Do you require to install the 23.0.1 version?

If you need version 23, please try 23.1.0. I suppose the main problem may be that the 23.x.x packages require ipywidgets<8 and this may get you in a dependency hell.

Could you try to install version 24.0.0 or master following https://github.com/TomographicImaging/CIL/tree/v24.0.0?tab=readme-ov-file#conda

paskino commented 4 months ago

@Cosme-liu can you also post the complete steps you are using in producing that error?

Is the conda environment activated? The error you encounter seems to point to the fact that the cil library is not found, which may be true if the right environment is not activated.

Cosme-liu commented 4 months ago

Hi @Cosme-liu

What version of conda/mamba do you have?

You are trying to install an older version of CIL. Do you require to install the 23.0.1 version?

If you need version 23, please try 23.1.0. I suppose the main problem may be that the 23.x.x packages require ipywidgets<8 and this may get you in a dependency hell.

Could you try to install version 24.0.0 or master following https://github.com/TomographicImaging/CIL/tree/v24.0.0?tab=readme-ov-file#conda

Hi @paskino It's not necessary to use version 23, but I failed to install the latest version:

conda install -c conda-forge -c intel -c ccpi cil=24.0.0

Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source.
Collecting package metadata (repodata.json): failed

And here's my conda version: image

Cosme-liu commented 4 months ago

@Cosme-liu can you also post the complete steps you are using in producing that error?

Is the conda environment activated? The error you encounter seems to point to the fact that the cil library is not found, which may be true if the right environment is not activated.

Hi @paskino I could successfully import cil, but failed to import cil.recon:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[9], line 2
      1 import cil
----> 2 import cil.recon

File D:\anaconda3\envs\cil\lib\site-packages\cil\recon\__init__.py:18
      1 # -*- coding: utf-8 -*-
      2 #   This work is part of the Core Imaging Library (CIL) developed by CCPi 
      3 #   (Collaborative Computational Project in Tomographic Imaging), with 
   (...)
     15 #   See the License for the specific language governing permissions and
     16 #   limitations under the License.
---> 18 from .Reconstructor import Reconstructor
     19 from .FBP import FBP
     20 from .FBP import FDK

File D:\anaconda3\envs\cil\lib\site-packages\cil\recon\Reconstructor.py:18
      1 # -*- coding: utf-8 -*-
      2 #   This work is part of the Core Imaging Library (CIL) developed by CCPi 
      3 #   (Collaborative Computational Project in Tomographic Imaging), with 
   (...)
     15 #   See the License for the specific language governing permissions and
     16 #   limitations under the License.
---> 18 from cil.framework import AcquisitionData, ImageGeometry, DataOrder
     19 import importlib
     20 import weakref

File D:\anaconda3\envs\cil\lib\site-packages\cil\framework\__init__.py:22
     20 import warnings
     21 from functools import reduce
---> 22 from .framework import cilacc
     23 from .framework import DataContainer
     24 from .framework import ImageData, AcquisitionData

File D:\anaconda3\envs\cil\lib\site-packages\cil\framework\framework.py:40
     37 else:
     38     raise ValueError('Not supported platform, ', platform.system())
---> 40 cilacc = ctypes.cdll.LoadLibrary(dll)
     42 def find_key(dic, val):
     43     """return the key of dictionary dic given the value"""

File D:\anaconda3\envs\cil\lib\ctypes\__init__.py:452, in LibraryLoader.LoadLibrary(self, name)
    451 def LoadLibrary(self, name):
--> 452     return self._dlltype(name)

File D:\anaconda3\envs\cil\lib\ctypes\__init__.py:364, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    362 import nt
    363 mode = nt._LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
--> 364 if '/' in name or '\\' in name:
    365     self._name = nt._getfullpathname(self._name)
    366     mode |= nt._LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR

TypeError: argument of type 'NoneType' is not iterable
paskino commented 4 months ago

We've had problems in solving the environment with conda <23.10. Therefore we suggest you to upgrade conda to a newer version than what you have and >23.10, where a different solver is used.

This should allow you to install the latest version of CIL.

Cosme-liu commented 4 months ago

We've had problems in solving the environment with conda <23.10. Therefore we suggest you to upgrade conda to a newer version than what you have and >23.10, where a different solver is used.

This should allow you to install the latest version of CIL.

After upgrading to conda 24.5.0 and cil 24.0.0, it works. Thank you!