Error running TotalSegmentator - returned non-zero exit status 120

I installed pytorch module and totalsegmentator in extensions manager then nii was imported ,but after I clicking “apply” and waiting for the process“TotalSegmentator Python package is required. Installing… (it may take several minutes)”,then the error info poped out。Need help to solve this,thx!
Here are the error infos。
Failed to compute results.
Command '[‘C:/ProgramData/NA-MIC/Slicer 5.2.2/bin/…/bin\PythonSlicer.EXE’, ‘-m’, ‘pip’, ‘install’, 'https://github.com/wasserth/TotalSegmentator/archive/b38eb449ad8652a987878a925203cbfa354e9b85.zip’]’ returned non-zero exit status 1.

Based on the provided information I believe this is the following issue linked below. The current workaround is to restart Slicer after the TotalSegmentor python package is installed and it should proceed successfully.

2 Likes

hi

I installed totalsegmentator and pytorch
I loaded demo CT data

Getting the following error:

Command ‘[‘C:/Users/drvka/AppData/Local/slicer.org/Slicer 5.7.0-2023-12-11/bin/…/bin\PythonSlicer.EXE’, ‘C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Scripts\TotalSegmentator.exe’, ‘-i’, ‘C:/Users/drvka/AppData/Local/Temp/Slicer/__SlicerTemp__2023-12-17_22+28+40.501/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/drvka/AppData/Local/Temp/Slicer/__SlicerTemp__2023-12-17_22+28+40.501/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 120.

ON CLICKING MORE DETAILS:

Traceback (most recent call last):
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\bin\Python\slicer\util.py”, line 3255, in tryWithErrorDisplay
yield
File “C:/Users/drvka/AppData/Local/slicer.org/Slicer 5.7.0-2023-12-11/slicer.org/Extensions-32642/TotalSegmentator/lib/Slicer-5.7/qt-scripted-modules/TotalSegmentator.py”, line 292, in onApplyButton
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),
File “C:/Users/drvka/AppData/Local/slicer.org/Slicer 5.7.0-2023-12-11/slicer.org/Extensions-32642/TotalSegmentator/lib/Slicer-5.7/qt-scripted-modules/TotalSegmentator.py”, line 967, in process
self.logProcessOutput(proc)
File “C:/Users/drvka/AppData/Local/slicer.org/Slicer 5.7.0-2023-12-11/slicer.org/Extensions-32642/TotalSegmentator/lib/Slicer-5.7/qt-scripted-modules/TotalSegmentator.py”, line 787, in logProcessOutput
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)
subprocess.CalledProcessError: Command ‘[‘C:/Users/drvka/AppData/Local/slicer.org/Slicer 5.7.0-2023-12-11/bin/…/bin\PythonSlicer.EXE’, ‘C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Scripts\TotalSegmentator.exe’, ‘-i’, ‘C:/Users/drvka/AppData/Local/Temp/Slicer/__SlicerTemp__2023-12-17_22+28+40.501/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/drvka/AppData/Local/Temp/Slicer/__SlicerTemp__2023-12-17_22+28+40.501/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 120.

Processing started
Writing input file to C:/Users/drvka/AppData/Local/Temp/Slicer/__SlicerTemp__2023-12-17_22+28+40.501/total-segmentator-input.nii
Creating segmentations with TotalSegmentator AI…
Total Segmentator arguments: [‘-i’, ‘C:/Users/drvka/AppData/Local/Temp/Slicer/__SlicerTemp__2023-12-17_22+28+40.501/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/drvka/AppData/Local/Temp/Slicer/__SlicerTemp__2023-12-17_22+28+40.501/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]
Traceback (most recent call last):
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\runpy.py”, line 197, in _run_module_as_main
return run_code(code, main_globals, None,
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\runpy.py”, line 87, in run_code
exec(code, run_globals)
File "C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Scripts\TotalSegmentator.exe_main
.py", line 7, in
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\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 “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\site-packages\totalsegmentator\python_api.py”, line 293, in totalsegmentator
seg_img, ct_img = nnUNet_predict_image(input, output, task_id, model=model, folds=folds,
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py”, line 395, in nnUNet_predict_image
nnUNetv2_predict(tmp_dir, tmp_dir, task_id, model, folds, trainer, tta,
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py”, line 178, in nnUNetv2_predict
predict_from_raw_data(dir_in,
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\site-packages\nnunetv2\inference\predict_from_raw_data.py”, line 159, in predict_from_raw_data
load_what_we_need(model_training_output_dir, use_folds, checkpoint_name)
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\site-packages\nnunetv2\inference\predict_from_raw_data.py”, line 96, in load_what_we_need
trainer_class = recursive_find_python_class(join(nnunetv2.path[0], “training”, “nnUNetTrainer”),
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\site-packages\nnunetv2\utilities\find_class_by_name.py”, line 12, in recursive_find_python_class
m = importlib.import_module(current_module + “.” + modname)
File "C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 850, in exec_module
File “”, line 228, in _call_with_frames_removed
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\site-packages\nnunetv2\training\nnUNetTrainer\nnUNetTrainer.py”, line 43, in
from nnunetv2.training.logging.nnunet_logger import nnUNetLogger
File “C:\Users\drvka\AppData\Local\slicer.org\Slicer 5.7.0-2023-12-11\lib\Python\Lib\site-packages\nnunetv2\training\logging\nnunet_logger.py”, line 1, in
import matplotlib
ModuleNotFoundError: No module named ‘matplotlib’
Exception ignored in: <totalsegmentator.libs.DummyFile object at 0x000001C347AEC6A0>
AttributeError: ‘DummyFile’ object has no attribute ‘flush’

please advise how to run totalsegmentator and solve the above issue

thanks


so I figured out

In the advanced option I forced reinstall python packages for total segmentor and it is working now

Leaving this here in case it helps others who might run into similar problems

2 Likes