After installing Slicer 5.2.2, Total Segmentator is no longer working. I read through the troubleshooting and uninstalled/reinstalled PyTorch and did a Force reinstall of Total Segmentator, but still can’t run it. I’m just using one of the cardiac sample datasets, so it’s small. The error is saying that the “scikit-learn” distribution is not found.
Processing started
Writing input file to C:/Users/starb/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-03_08+02+51.749/total-segmentator-input.nii
Creating segmentations with TotalSegmentator AI...
Total Segmentator arguments: ['-i', 'C:/Users/starb/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-03_08+02+51.749/total-segmentator-input.nii', '-o', 'C:/Users/starb/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-03_08+02+51.749/segmentation', '--ml', '--task', 'total']
Traceback (most recent call last):
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Scripts\TotalSegmentator", line 93, in <module>
main()
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Scripts\TotalSegmentator", line 82, in main
parser.add_argument('--version', action='version', version=require("TotalSegmentator")[0].version)
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 956, in require
needed = self.resolve(parse_requirements(requirements))
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 815, in resolve
dist = self._resolve_dist(
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 856, in _resolve_dist
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'scikit-learn' distribution was not found and is required by batchgenerators, nnunet-customized
Just tested the whole process again (Windows 11, Laptop, GTX 1060 6 GB video RAM)
Downloaded Slicer 3.2.2
Installed into a fresh directory
Started 3D Slicer
Installed the Pytorch extension
Restarted
Installed the TotalSegmentator extension
Restarted
Loaded a test dataset
Switched to Totalsegmentator
Pressed “Apply”
Received one error message during the following installation processes (torch etc). This is a known error that happens every time during first installation. We are working to find a solution here.
I went through this a few times and managed to achieve something different if I uninstalled PyTorch, restarted, and let Total Segmentator install it on the first run, restarted, ran TS again and got this:
Processing started
Writing input file to C:/Users/starb/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-03_09+56+09.275/total-segmentator-input.nii
Creating segmentations with TotalSegmentator AI...
Total Segmentator arguments: ['-i', 'C:/Users/starb/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-03_09+56+09.275/total-segmentator-input.nii', '-o', 'C:/Users/starb/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-03_09+56+09.275/segmentation', '--ml', '--task', 'total']
Traceback (most recent call last):
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Scripts\TotalSegmentator", line 93, in <module>
main()
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Scripts\TotalSegmentator", line 82, in main
parser.add_argument('--version', action='version', version=require("TotalSegmentator")[0].version)
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 956, in require
needed = self.resolve(parse_requirements(requirements))
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 815, in resolve
dist = self._resolve_dist(
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 844, in _resolve_dist
env = Environment(self.entries)
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 1044, in __init__
self.scan(search_path)
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 1077, in scan
self.add(dist)
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 1096, in add
dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 2631, in hashcmp
self.parsed_version,
File "C:\Users\starb\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\site-packages\pkg_resources\__init__.py", line 2685, in parsed_version
raise packaging.version.InvalidVersion(f"{str(ex)} {info}") from None
pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: 'rch' (package: -)
It’s finally working now. I noticed each time I reinstalled 5.2.2 that my extensions were still there, so I uninstalled 5.2.1 and removed all the files that were left in the NA-MIC folder, followed your steps above and it worked.
Each Slicer installation is independent, so having Slicer-5.2.1 does not affect 5.2.2 at all.
Slicer-5.2.2 has the issue that it has an updated scipy (1.9.2) that scikit-image refuses to work with. I’ve pushed a fix to the TotalSegmentator extension that guides you through how to install a compatible scipy version. This is not the same scikit-learn issue that you described above but maybe they are related.
Please install Slicer-5.2.2 from scratch into a new folder, install the latest TotalSegmentator version (that is available from tomorrow - 2023-04-04 - 10am EST) and see if it starts up correctly. It will ask you to restart the application the first time you use it.
What version number is printed if you run this command in the Python console in Slicer?
import scipy; print(scipy.__version__)
If it is 1.9.2 then try to restart the computer, because probable some files kept open on your computer (maybe another Slicer instance is running) and restarting your computer is guaranteed to close them. Right after restart, try running TotalSegmentator again. It will ask for Slicer restart and after that then scipy version should be 1.9.1. If it is still not 1.9.1 then restart your computer again (to close all open files) and run this command in a Windows command prompt to install scipy-1.9.1:
I assumed that you use the current stable version of Slicer, installed in the default location, that’s why I provided this command: "%localappdata%\NA-MIC\Slicer 5.2.2\bin\PythonSlicer.exe" -m pip install --upgrade pip install scipy==1.9.1
It seems that you use a preview release installed in a custom location, so you need to use C:\SlicerInstall\Slicer 5.3.0\bin\PythonSlicer.EXE instead.
That said, it seems that your managed to install all prerequisites, because TotalSegmentator was launched. However, I don’t see any specific error messages from TotalSegmentator, only that the final error code was nonzero. To solve the problem, we need more information. Check the module GUI and the application log and copy here all the details. Since you seem to have a very slow and unreliable network connection, the problem is quite likely an inconvenience nolete download of one of the Python packages or the TotalSegmentator model weights.