TotalSegmentator error at first run: returned non-zero exit status 120.

Dear all

I tried to use the TotalSegmentator in 3D slicer, but I got an error:

Failed to compute results.

Traceback (most recent call last):
File “E:\3D Slicer\Slicer 5.6.1\bin\Python\slicer\util.py”, line 3255, in tryWithErrorDisplay
yield
File “E:/3D Slicer/Slicer 5.6.1/slicer.org/Extensions-32438/TotalSegmentator/lib/Slicer-5.6/qt-scripted-modules/TotalSegmentator.py”, line 292, in onApplyButton
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),
File “E:/3D Slicer/Slicer 5.6.1/slicer.org/Extensions-32438/TotalSegmentator/lib/Slicer-5.6/qt-scripted-modules/TotalSegmentator.py”, line 967, in process
self.logProcessOutput(proc)
File “E:/3D Slicer/Slicer 5.6.1/slicer.org/Extensions-32438/TotalSegmentator/lib/Slicer-5.6/qt-scripted-modules/TotalSegmentator.py”, line 787, in logProcessOutput
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command ‘[‘E:/3D Slicer/Slicer 5.6.1/bin/…/bin\PythonSlicer.EXE’, ‘E:\3D Slicer\Slicer 5.6.1\lib\Python\Scripts\TotalSegmentator.exe’, ‘-i’, ‘C:/Users/xrnyy/AppData/Local/Temp/Slicer/__SlicerTemp__2024-02-20_22+51+14.310/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/xrnyy/AppData/Local/Temp/Slicer/__SlicerTemp__2024-02-20_22+51+14.310/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 120.

Then the error reported under the “Apply” button :

Processing started
Writing input file to C:/Users/xrnyy/AppData/Local/Temp/Slicer/__SlicerTemp__2024-02-20_22+51+14.310/total-segmentator-input.nii
Creating segmentations with TotalSegmentator AI…
Total Segmentator arguments: [‘-i’, ‘C:/Users/xrnyy/AppData/Local/Temp/Slicer/__SlicerTemp__2024-02-20_22+51+14.310/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/xrnyy/AppData/Local/Temp/Slicer/__SlicerTemp__2024-02-20_22+51+14.310/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]
Traceback (most recent call last):
File “E:\3D Slicer\Slicer 5.6.1\lib\Python\Lib\runpy.py”, line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File “E:\3D Slicer\Slicer 5.6.1\lib\Python\Lib\runpy.py”, line 87, in run_code
exec(code, run_globals)
File "E:\3D Slicer\Slicer 5.6.1\lib\Python\Scripts\TotalSegmentator.exe_main
.py", line 7, in
File “E:\3D Slicer\Slicer 5.6.1\lib\Python\Lib\site-packages\totalsegmentator\bin\TotalSegmentator.py”, line 127, in main
totalsegmentator(args.input, args.output, args.ml, args.nr_thr_resamp, args.nr_thr_saving,
File “E:\3D Slicer\Slicer 5.6.1\lib\Python\Lib\site-packages\totalsegmentator\python_api.py”, line 77, in totalsegmentator
from totalsegmentator.nnunet import nnUNet_predict_image # this has to be after setting new env vars
File “E:\3D Slicer\Slicer 5.6.1\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py”, line 23, in
from nnunetv2.inference.predict_from_raw_data import predict_from_raw_data
ModuleNotFoundError: No module named ‘nnunetv2’
Exception ignored in: <totalsegmentator.libs.DummyFile object at 0x000002840C2953A0>
AttributeError: ‘DummyFile’ object has no attribute ‘flush’

If you use this tool please cite: https://pubs.rsna.org/doi/10.1148/ryai.230024

Thank you very much for the support!

Please see the following post regarding a required workaround. Note this may change as the various dependencies of the TotalSegmentator python package change.