# Total Segmentator on 5.2.2 "scikit-learn" distribution not found

**URL:** <https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727>\
**Category:** Support\
**Created:** [April 3, 2023, 12:07pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727 "2023-04-03T12:07:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsehrhardt](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tsehrhardt/32/18470_2.png) [@tsehrhardt](https://discourse.slicer.org/u/tsehrhardt)\
**Post date:** [April 3, 2023, 12:07pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/1 "2023-04-03T12:07:02Z")

</div>

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.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [April 3, 2023, 12:53pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/2 "2023-04-03T12:53:12Z")

</div>

Hello, on which operating system are you?

---

<div class="post-metadata">

**Author:** ![tsehrhardt](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tsehrhardt/32/18470_2.png) [@tsehrhardt](https://discourse.slicer.org/u/tsehrhardt)\
**Post date:** [April 3, 2023, 12:55pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/3 "2023-04-03T12:55:03Z")

</div>

I am using Windows 10.

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [April 3, 2023, 1:27pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/4 "2023-04-03T13:27:12Z")

</div>

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.
- Restarted Slicer
- Switched to Totalsegmentator
- Pressed “Apply” (fast mode)
- installation continues, then segmentation
- Got a good segmentation result.

---

<div class="post-metadata">

**Author:** ![tsehrhardt](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tsehrhardt/32/18470_2.png) [@tsehrhardt](https://discourse.slicer.org/u/tsehrhardt)\
**Post date:** [April 3, 2023, 1:59pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/5 "2023-04-03T13:59:53Z")

</div>

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:

```auto
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: -)

```

This is the PyTorch version installed by TS:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/7/975be04585bd12ae2a9e63cdeaca9e186f2f0cd1.png)

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [April 3, 2023, 2:48pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/6 "2023-04-03T14:48:56Z")

</div>

> [@tsehrhardt](#):
>
> `pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: 'rch' (package: -)`

Had you freshly installed 3D Slicer before that?

---

<div class="post-metadata">

**Author:** ![tsehrhardt](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tsehrhardt/32/18470_2.png) [@tsehrhardt](https://discourse.slicer.org/u/tsehrhardt)\
**Post date:** [April 3, 2023, 4:14pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/7 "2023-04-03T16:14:12Z")

</div>

Yes I uninstalled it then reinstalled it. I still have 5.2.1 installed as well–would that matter?

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [April 3, 2023, 4:18pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/9 "2023-04-03T16:18:28Z")

</div>

Not if you newly installed 5.2.2. @lassoan do you have any ideas?

---

<div class="post-metadata">

**Author:** ![tsehrhardt](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tsehrhardt/32/18470_2.png) [@tsehrhardt](https://discourse.slicer.org/u/tsehrhardt)\
**Post date:** [April 3, 2023, 6:37pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/10 "2023-04-03T18:37:15Z")

</div>

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.

Thanks so much for your help!

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [April 3, 2023, 6:40pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/11 "2023-04-03T18:40:09Z")

</div>

Excellent, great job.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 3, 2023, 9:05pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/12 "2023-04-03T21:05:05Z")

</div>

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](https://github.com/lassoan/SlicerTotalSegmentator/commit/392c53e9f465dca07f0008495a569d077f5630bd) 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.

---

<div class="post-metadata">

**Author:** ![tsehrhardt](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tsehrhardt/32/18470_2.png) [@tsehrhardt](https://discourse.slicer.org/u/tsehrhardt)\
**Post date:** [April 4, 2023, 4:20pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/13 "2023-04-04T16:20:58Z")

</div>

Thanks! I’ll try today as well to see what happens.

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [April 4, 2023, 5:20pm UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/14 "2023-04-04T17:20:47Z")

</div>

Fresh installation: It now works as expected and described in your above post. Thank you.

---

<div class="post-metadata">

**Author:** ![JulioSansone](https://avatars.discourse-cdn.com/v4/letter/j/839c29/32.png) [@JulioSansone](https://discourse.slicer.org/u/JulioSansone)\
**Post date:** [April 21, 2023, 5:36am UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/15 "2023-04-21T05:36:11Z")

</div>

> [@lassoan](#):
>
> 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](https://github.com/lassoan/SlicerTotalSegmentator/commit/392c53e9f465dca07f0008495a569d077f5630bd) 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.

Thanks, I will try it.

---

<div class="post-metadata">

**Author:** ![whu](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@whu](https://discourse.slicer.org/u/whu)\
**Post date:** [April 25, 2023, 1:51am UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/16 "2023-04-25T01:51:47Z")

</div>

> [@lassoan](#):
>
> u

I installed the Slicer 5.3.0 + TotalSegmentator Apr 24 2023 version, it still ask to restart the slicer again and again , how to solve it ?  
thanks.

---

<div class="post-metadata">

**Author:** ![whu](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@whu](https://discourse.slicer.org/u/whu)\
**Post date:** [April 25, 2023, 2:04am UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/17 "2023-04-25T02:04:48Z")

</div>

win10 + Slicer 3.3 + Total Segmentator 4.23 , still get the “This module requires installing scipy version \<1.9.2,”

thanks.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 25, 2023, 2:50am UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/18 "2023-04-25T02:50:47Z")

</div>

What version number is printed if you run this command in the Python console in Slicer?

```auto
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:

```auto
"%localappdata%\NA-MIC\Slicer 5.2.2\bin\PythonSlicer.exe" -m pip install --upgrade pip install scipy==1.9.1

```

Please copy the entire output of the command here.

---

<div class="post-metadata">

**Author:** ![whu](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@whu](https://discourse.slicer.org/u/whu)\
**Post date:** [April 25, 2023, 5:47am UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/19 "2023-04-25T05:47:57Z")

</div>

> [@lassoan](#):
>
> ```auto
> "%localappdata%\NA-MIC\Slicer 5.2.2\bin\PythonSlicer.exe" -m pip install --upgrade pip install scipy==1.9.1
> 
> ```

this get help, and latter it will download the pytorch 2.0 again, this was too slow.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/1/61d9a13327c04c9a1eb9466f078498e746d73ae8.png)  
even dead…  
I have installed the pytorch extension before the Totalsegmentator.

---

<div class="post-metadata">

**Author:** ![whu](https://avatars.discourse-cdn.com/v4/letter/w/7ab992/32.png) [@whu](https://discourse.slicer.org/u/whu)\
**Post date:** [April 25, 2023, 7:54am UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/20 "2023-04-25T07:54:29Z")

</div>

After long time trying, the Totalsegmentator installed.  
when using the example dataset from the github code:ct\_3mm.nii  
the error is as follows:

Traceback (most recent call last):  
File “C:\SlicerInstall\Slicer 5.3.0\bin\Python\slicer\util.py”, line 2973, in tryWithErrorDisplay  
yield  
File “C:/SlicerInstall/Slicer 5.3.0/slicer.org/Extensions-31730/TotalSegmentator/lib/Slicer-5.3/qt-scripted-modules/TotalSegmentator.py”, line 264, in onApplyButton  
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),  
File “C:/SlicerInstall/Slicer 5.3.0/slicer.org/Extensions-31730/TotalSegmentator/lib/Slicer-5.3/qt-scripted-modules/TotalSegmentator.py”, line 799, in process  
self.logProcessOutput(proc)  
File “C:/SlicerInstall/Slicer 5.3.0/slicer.org/Extensions-31730/TotalSegmentator/lib/Slicer-5.3/qt-scripted-modules/TotalSegmentator.py”, line 692, in logProcessOutput  
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)  
subprocess.CalledProcessError: Command ‘[‘C:/SlicerInstall/Slicer 5.3.0/bin/…/bin\PythonSlicer.EXE’, ‘C:\SlicerInstall\Slicer 5.3.0\lib\Python\Scripts\TotalSegmentator’, ‘-i’, ‘C:/Users/wxxx/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2023-04-25\_15+50+32.050/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/wxxx/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2023-04-25\_15+50+32.050/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 1.

the same data on the Totalsegmentator online was successful.  
so, what is the problem ?  
thanks.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 25, 2023, 11:09am UTC](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727/21 "2023-04-25T11:09:56Z")

</div>

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.

[Next page](https://discourse.slicer.org/t/total-segmentator-on-5-2-2-scikit-learn-distribution-not-found/28727.md?page=2)
