wasserth / TotalSegmentator

Tool for robust segmentation of >100 important anatomical structures in CT and MR images
Apache License 2.0
1.55k stars 255 forks source link

ModuleNotFoundError: No module named 'blosc2' #385

Open ASHISRAVINDRAN opened 2 weeks ago

ASHISRAVINDRAN commented 2 weeks ago

Hi @wasserth I am from the MITK development team working to update TotalSegmentator to v2.4 for our upcoming release. I am testing out installing TotalSegmentator via MITK and I see that TotalSegmentator has stopped working due to import errors. Error log:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\DKFZ\TotalSegmentator_work\.venv_7Nov\Scripts\TotalSegmentator.exe\__main__.py", line 7, in <module>
  File "C:\DKFZ\TotalSegmentator_work\.venv_7Nov\Lib\site-packages\totalsegmentator\bin\TotalSegmentator.py", line 138, in main
    totalsegmentator(args.input, args.output, args.ml, args.nr_thr_resamp, args.nr_thr_saving,
  File "C:\DKFZ\TotalSegmentator_work\.venv_7Nov\Lib\site-packages\totalsegmentator\python_api.py", line 126, in totalsegmentator
    from totalsegmentator.nnunet import nnUNet_predict_image  # this has to be after setting new env vars
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\DKFZ\TotalSegmentator_work\.venv_7Nov\Lib\site-packages\totalsegmentator\nnunet.py", line 30, in <module>
    from nnunetv2.inference.predict_from_raw_data import nnUNetPredictor
  File "C:\DKFZ\TotalSegmentator_work\.venv_7Nov\Lib\site-packages\nnunetv2\inference\predict_from_raw_data.py", line 22, in <module>
    from nnunetv2.inference.data_iterators import PreprocessAdapterFromNpy, preprocessing_iterator_fromfiles, \
  File "C:\DKFZ\TotalSegmentator_work\.venv_7Nov\Lib\site-packages\nnunetv2\inference\data_iterators.py", line 12, in <module>
    from nnunetv2.preprocessing.preprocessors.default_preprocessor import DefaultPreprocessor
  File "C:\DKFZ\TotalSegmentator_work\.venv_7Nov\Lib\site-packages\nnunetv2\preprocessing\preprocessors\default_preprocessor.py", line 25, in <module>
    from nnunetv2.preprocessing.cropping.cropping import crop_to_nonzero
  File "C:\DKFZ\TotalSegmentator_work\.venv_7Nov\Lib\site-packages\nnunetv2\preprocessing\cropping\cropping.py", line 5, in <module>
    from acvl_utils.cropping_and_padding.bounding_boxes import get_bbox_from_mask, crop_to_bbox, bounding_box_to_slice
  File "C:\DKFZ\TotalSegmentator_work\.venv_7Nov\Lib\site-packages\acvl_utils\cropping_and_padding\bounding_boxes.py", line 5, in <module>
    import blosc2
ModuleNotFoundError: No module named 'blosc2'

Merely pip installing blosc2 leads to even more import errors. It would be great if you can take a look.

krekiehn commented 2 weeks ago

same for me

Win10 & Ubuntu TotalSegmentator 2.4.0 python 3.9

pip freeze: acvl_utils==0.2.1 batchgenerators==0.25.1 batchgeneratorsv2==0.2.1 certifi==2024.8.30 charset-normalizer==2.0.12 connected-components-3d==3.19.0 contourpy==1.3.0 cycler==0.12.1 dataclasses==0.6 dicom2nifti==2.5.0 dill==0.3.9 dynamic_network_architectures==0.3.1 einops==0.8.0 fft-conv-pytorch==1.2.0 filelock==3.16.1 fonttools==4.54.1 fsspec==2024.10.0 future==1.0.0 graphviz==0.20.3 idna==3.10 imagecodecs==2024.9.22 imageio==2.36.0 importlib_resources==6.4.5 Jinja2==3.1.4 joblib==1.4.2 kiwisolver==1.4.7 lazy_loader==0.4 linecache2==1.0.0 MarkupSafe==3.0.2 matplotlib==3.9.2 mpmath==1.3.0 multiprocess==0.70.17 networkx==3.2.1 nibabel==5.3.2 nnunetv2==2.5.1 numpy==1.26.4 nvidia-cublas-cu12==12.4.5.8 nvidia-cuda-cupti-cu12==12.4.127 nvidia-cuda-nvrtc-cu12==12.4.127 nvidia-cuda-runtime-cu12==12.4.127 nvidia-cudnn-cu12==9.1.0.70 nvidia-cufft-cu12==11.2.1.3 nvidia-curand-cu12==10.3.5.147 nvidia-cusolver-cu12==11.6.1.9 nvidia-cusparse-cu12==12.3.1.170 nvidia-nccl-cu12==2.21.5 nvidia-nvjitlink-cu12==12.4.127 nvidia-nvtx-cu12==12.4.127 opencv-python==4.10.0.84 p_tqdm==1.4.2 packaging==24.2 pandas==2.2.3 pathos==0.3.3 pillow==11.0.0 pkg_resources==0.0.0 pox==0.3.5 ppft==1.7.6.9 pyarrow==18.0.0 pydicom==2.4.4 pyparsing==3.2.0 python-dateutil==2.9.0.post0 python-gdcm==3.0.24.1 pytz==2024.2 PyYAML==6.0.2 requests==2.27.1 rt-utils==1.2.7 scikit-image==0.24.0 scikit-learn==1.5.2 scipy==1.13.1 seaborn==0.13.2 SimpleITK==2.4.0 six==1.16.0 sympy==1.13.1 threadpoolctl==3.5.0 tifffile==2024.8.30 torch==2.5.1 torchaudio==2.5.1 torchvision==0.20.1 TotalSegmentator==2.4.0 tqdm==4.67.0 traceback2==1.4.0 triton==3.1.0 typing_extensions==4.12.2 tzdata==2024.2 unittest2==1.1.0 urllib3==1.26.20 xvfbwrapper==0.2.9 yacs==0.1.8 zipp==3.20.2

krekiehn commented 2 weeks ago

here is a solution from nnunet repo:

https://github.com/MIC-DKFZ/nnUNet/issues/2589#issuecomment-2464528411

mibadev commented 2 weeks ago

Do you have blosc2 installed in your venv? Activate your venv than check pip install blosc2 test install python -c "import blosc2"

ASHISRAVINDRAN commented 1 week ago

I see this issue is mostly fixed now, except on Python 3.9. I believe this comes from acvl_utils v0.2.2. See: https://github.com/MIC-DKFZ/acvl_utils/commit/4cad0deb89dc97b6f4ecfdfd553b994bee076274 where the blosc2>=3.0.0b4 is needed as dependency. A pip wheel doesn't seem exist for blosc>2.5 on Python 3.9. This renders TotalSegmentator not working on python 3.9