TotalSegmentator failed to install required packages

I keep having a similar issue - how do I fix this? Thanks!

Does it work in Slicer 5.12.1? We made a fix related to this in the 5.12.1 patch (BUG: Disable pip install UI off main thread · Slicer/Slicer@c2975f2 · GitHub)

Related discussion: Nninteractive (slicer client) is stuck

I’m not familiar enough with the packacking.py and related code to provide a professional opinion on whether this is truly fixed. My only concern is that it started working for me in 5.12 and I have not updated to 5.12.1. My understanding was the extensions manager server code had been updated to resolve this issue.

Hi, I’ve been having this same issue. I updated to 5.12.1, and still have the issue. I even tried downgrading to earlier versions, and have the issue (after fully uninstalling and deleting related files). I also tried using MONAI instead, and ran into the same exact error (near verbatim). I tried uninstalling all forms of Python, including any apps that may have their own Python dependencies (VSCode, Pycharm, etc.) because it almost seemed to be unable to find Pytorch despite it being there. I tried the (likely not recommended) method of manually moving/duplicating package scripts into where I know it’s checking, with no luck. I even used pip install to check, and it says Torchgen is already installed, same with torchvision. This is the error message I get:

Traceback (most recent call last):
  File "C:/Users/madim/AppData/Local/slicer.org/3D Slicer 5.12.1/slicer.org/Extensions-34624/TotalSegmentator/lib/Slicer-5.12/qt-scripted-modules/TotalSegmentator.py", line 319, in onApplyButton
    self.logic.setupPythonRequirements()
  File "C:/Users/madim/AppData/Local/slicer.org/3D Slicer 5.12.1/slicer.org/Extensions-34624/TotalSegmentator/lib/Slicer-5.12/qt-scripted-modules/TotalSegmentator.py", line 847, in setupPythonRequirements
    if not torchLogic.torchInstalled():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:/Users/madim/AppData/Local/slicer.org/3D Slicer 5.12.1/slicer.org/Extensions-34624/PyTorch/lib/Slicer-5.12/qt-scripted-modules/PyTorchUtils.py", line 162, in torchInstalled
    metadataPath = [p for p in importlib.metadata.files('torch') if 'METADATA' in str(p)][0]
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
[Python] Failed to install required packages.
[Python] 'NoneType' object is not iterable

Okay so I think I may have fixed it: for me, when I install slicer it automatically wants to be installed inside AppData, so I tried uninstalling it, then reinstalling the latest version just inside my C drive. I did not put it inside any subfolder, and now it appears to be working. I think if you let it install inside AppData the pathing for finding packages gets wonky.

Hi Madisyn! Thanks so much for your tips, I uninstalled and reinstalled Slicer in the C:\ drive and was finally able to download TotalSegmentator. When I tried to run it, I got the following error:

And noticed it was still pulling a path from AppData. Do you have any recommendations? Thanks again!

Is there any real help to fix this issue? None of the previous versions has ever been so stubborn as this 5.12.1 Total Segmentator

Yes, this is fixed in the latest Slicer Stable Release (Slicer-5.12.3) and latest Slicer Preview Releases. When you see a notification at startup that a new Slicer release is available then you need to install it if you want to get latest extension bugfixes and improvements.