# TotalSegmentator error at first run: Command ...Python\\Scripts\\TotalSegmentator... returned non-zero exit status 120

**URL:** <https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [December 15, 2022, 2:41pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755 "2022-12-15T14:41:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Augusto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/augusto/32/17710_2.png) [@Augusto](https://discourse.slicer.org/u/Augusto)\
**Post date:** [December 15, 2022, 2:41pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/1 "2022-12-15T14:41:15Z")

</div>

In line with this error, i get a similar one and don’t know why:

Traceback (most recent call last):  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\bin\Python\slicer\util.py”, line 2961, in tryWithErrorDisplay  
yield  
File “C:/Users/Augusto/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 258, in onApplyButton  
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),  
File “C:/Users/Augusto/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 716, in process  
self.logProcessOutput(proc)  
File “C:/Users/Augusto/AppData/Local/NA-MIC/Slicer 5.2.1/NA-MIC/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 625, in logProcessOutput  
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)  
subprocess.CalledProcessError: Command ‘[‘C:/Users/Augusto/AppData/Local/NA-MIC/Slicer 5.2.1/bin/…/bin\PythonSlicer.EXE’, ‘C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Scripts\TotalSegmentator’, ‘-i’, ‘C:/Users/Augusto/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2022-12-15\_14+38+59.132/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/Augusto/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2022-12-15\_14+38+59.132/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 120.

Anyone can help?

---

<div class="post-metadata">

**Author:** ![Augusto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/augusto/32/17710_2.png) [@Augusto](https://discourse.slicer.org/u/Augusto)\
**Post date:** [December 15, 2022, 2:43pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/2 "2022-12-15T14:43:54Z")

</div>

I have tried this and the extension is properly installed.

---

<div class="post-metadata">

**Author:** ![don\_balon](https://avatars.discourse-cdn.com/v4/letter/d/b3f665/32.png) [@don\_balon](https://discourse.slicer.org/u/don_balon)\
**Post date:** [December 15, 2022, 4:50pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/3 "2022-12-15T16:50:18Z")

</div>

I have the same problem.  
Tried installing Slicer several times, both 5.2.1 stable or 5.3.0 dev. version.  
Installed Git.  
Still same error, as Augusto mentioned.  
Any help? ☹

Traceback (most recent call last):  
File “C:\Users\rstando\AppData\Local\NA-MIC\Slicer\bin\Python\slicer\util.py”, line 2963, in tryWithErrorDisplay  
yield  
File “C:/Users/rstando/AppData/Local/NA-MIC/Slicer/NA-MIC/Extensions-31464/TotalSegmentator/lib/Slicer-5.3/qt-scripted-modules/TotalSegmentator.py”, line 258, in onApplyButton  
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),  
File “C:/Users/rstando/AppData/Local/NA-MIC/Slicer/NA-MIC/Extensions-31464/TotalSegmentator/lib/Slicer-5.3/qt-scripted-modules/TotalSegmentator.py”, line 715, in process  
self.logProcessOutput(proc)  
File “C:/Users/rstando/AppData/Local/NA-MIC/Slicer/NA-MIC/Extensions-31464/TotalSegmentator/lib/Slicer-5.3/qt-scripted-modules/TotalSegmentator.py”, line 624, in logProcessOutput  
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)  
subprocess.CalledProcessError: Command ‘[‘C:/Users/rstando/AppData/Local/NA-MIC/Slicer/bin/…/bin\PythonSlicer.EXE’, ‘C:\Users\rstando\AppData\Local\NA-MIC\Slicer\lib\Python\Scripts\TotalSegmentator’, ‘-i’, ‘C:/Users/rstando/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2022-12-15\_17+49+15.611/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/rstando/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2022-12-15\_17+49+15.611/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 120.

---

<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:** [December 15, 2022, 8:02pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/4 "2022-12-15T20:02:31Z")

</div>

Can you copy here the messages that are printed in the textbox below the Apply button?  
Does it work if you segment with a Slicer sample data set?

---

<div class="post-metadata">

**Author:** ![octajuan](https://avatars.discourse-cdn.com/v4/letter/o/6de8d8/32.png) [@octajuan](https://discourse.slicer.org/u/octajuan)\
**Post date:** [December 15, 2022, 9:06pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/5 "2022-12-15T21:06:33Z")

</div>

I´m having the exact same problem trying to run totalsegmentator.

---

<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:** [December 15, 2022, 9:09pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/6 "2022-12-15T21:09:32Z")

</div>

@octajuan I have the same questions to you, too:

- Can you copy here the messages that are printed in the textbox below the Apply button?
- Does it work if you segment with a Slicer sample data set?

---

<div class="post-metadata">

**Author:** ![Augusto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/augusto/32/17710_2.png) [@Augusto](https://discourse.slicer.org/u/Augusto)\
**Post date:** [December 15, 2022, 9:18pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/7 "2022-12-15T21:18:54Z")

</div>

For the time being, since i have slicer installed in a computer which, by default, has no internet acess, i cannot download the sample data set and test TotalSegmentator with it. As soon as i have acess to internet, i will try.

The messages that appear after the Apply button are as follows:

Processing started  
Writing input file to C:/Users/Augusto/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2022-12-15\_21+10+39.789/total-segmentator-input.nii  
Creating segmentations with TotalSegmentator AI…  
Total Segmentator arguments: [‘-i’, ‘C:/Users/Augusto/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2022-12-15\_21+10+39.789/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/Augusto/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2022-12-15\_21+10+39.789/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]

If you have questions or suggestions, feel free to open an issue at [GitHub - MIC-DKFZ/nnUNet](https://github.com/MIC-DKFZ/nnUNet)  
preprocessing C:\Users\Augusto\AppData\Local\Temp\nnunet\_tmp\_kqifjdkf\s01.nii.gz  
before crop: (1, 228, 171, 171) after crop: (1, 228, 171, 171) spacing: [3. 3. 3.]  
no resampling necessary  
before: {‘spacing’: array([3., 3., 3.]), ‘spacing\_transposed’: array([3., 3., 3.]), ‘data.shape (data is transposed)’: (1, 228, 171, 171)}

This worker has ended successfully, no errors to report  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Scripts\TotalSegmentator”, line 201, in   
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Scripts\TotalSegmentator”, line 179, in main  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py”, line 232, in nnUNet\_predict\_image  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py”, line 106, in nnUNet\_predict  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\nnunet\inference\predict.py”, line 668, in predict\_from\_folder  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\nnunet\inference\predict.py”, line 493, in predict\_cases\_fastest  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\nnunet\training\network\_training\nnUNetTrainerV2.py”, line 211, in predict\_preprocessed\_data\_return\_seg\_and\_softmax  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\nnunet\training\network\_training\nnUNetTrainer.py”, line 516, in predict\_preprocessed\_data\_return\_seg\_and\_softmax  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\nnunet\network\_architecture\neural\_network.py”, line 147, in predict\_3D  
File “C:\Users\Augusto\AppData\Local\NA-MIC\Slicer 5.2.1\lib\Python\Lib\site-packages\nnunet\network\_architecture\neural\_network.py”, line 356, in \_internal\_predict\_3D\_3Dconv\_tiled  
RuntimeError: CUDA out of memory. Tried to allocate 1.30 GiB (GPU 0; 2.00 GiB total capacity; 120.31 MiB already allocated; 1.17 GiB free; 150.00 MiB reserved in total by PyTorch)  
AttributeError: ‘DummyFile’ object has no attribute ‘flush’  
Resampling…  
Predicting…

---

<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:** [December 15, 2022, 9:33pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/8 "2022-12-15T21:33:10Z")

</div>

> [@Augusto](#):
>
> RuntimeError: CUDA out of memory.

Thank you for the report, it contained a nice and clear description of the error: you have run out of memory. 2GB GPU RAM is not nearly enough to do anything related to image segmentation.

You need to use your CPU. The easiest is to install the CPU version of pytorch by exiting Slicer and typing this into the Windows terminal:

```txt
"%localappdata%\NA-MIC\Slicer 5.2.1\bin\PythonSlicer.EXE" -m pip install torch torchvision torchaudio --force-reinstall

```

We have been discussing in the TotalSegmentator issue tracker how we could avoid this workaround to make switching to CPU easier in case the computer has a GPU but not powerful enough:

> <https://github.com/wasserth/TotalSegmentator/issues/37>
>
> Background: TotalSegmentator works extremely well. It stands out among other seg…mentation tools with its robustness and the large number of segments, but also with its low resource needs - especially that it can run on a CPU. While all developers have access to computers with CUDA-capable GPU, most users (and basically anyone using a laptop) don't have CUDA-capable GPU. Uploading patient data to some remote server is not acceptable for many users. So, TotalSegmentator is awesome, it allows anyone to segment their own data locally, very conveniently within 3D Slicer, by a few clicks - and the \[Slicer community is really excited about this\](https://discourse.slicer.org/t/new-extension-fully-automatic-whole-body-ct-segmentation-in-2-minutes-using-totalsegmentator/26710).
> 
> Problem: People who have a weak NVIDIA GPU (e.g., something like a 4GB GPU on a laptop) cannot currently get full-resolution segmentations because their GPU is detected (so CUDA is used) but they don't have enough GPU memory.
> 
> Would it be possible to add an option to TotalSegmentator to specify what device to use?
> 
> The options could be:
> \- \`automatic\`: the current method, use CUDA if available, otherwise CPU
> \- \`CPU\`: force to use CPU, even if CUDA-capable GPU is available

---

<div class="post-metadata">

**Author:** ![Augusto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/augusto/32/17710_2.png) [@Augusto](https://discourse.slicer.org/u/Augusto)\
**Post date:** [December 15, 2022, 9:47pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/9 "2022-12-15T21:47:52Z")

</div>

Ok, will do! Thank you very much!

---

<div class="post-metadata">

**Author:** ![don\_balon](https://avatars.discourse-cdn.com/v4/letter/d/b3f665/32.png) [@don\_balon](https://discourse.slicer.org/u/don_balon)\
**Post date:** [December 16, 2022, 7:49am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/10 "2022-12-16T07:49:01Z")

</div>

My CPU is burning, but now it works perfect!  
Thank you!

---

<div class="post-metadata">

**Author:** ![FraRizzetto](https://avatars.discourse-cdn.com/v4/letter/f/49beb7/32.png) [@FraRizzetto](https://discourse.slicer.org/u/FraRizzetto)\
**Post date:** [December 17, 2022, 3:11pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/11 "2022-12-17T15:11:53Z")

</div>

Hi all, I have just tried the extension in fast mode (because no GPU is detected) and it gives me a similar error:

Traceback (most recent call last):  
File “/Applications/Slicer.app/Contents/bin/Python/slicer/util.py”, line 2961, in tryWithErrorDisplay  
yield  
File “/Applications/Slicer.app/Contents/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 258, in onApplyButton  
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),  
File “/Applications/Slicer.app/Contents/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 715, in process  
self.logProcessOutput(proc)  
File “/Applications/Slicer.app/Contents/Extensions-31317/TotalSegmentator/lib/Slicer-5.2/qt-scripted-modules/TotalSegmentator.py”, line 624, in logProcessOutput  
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)  
subprocess.CalledProcessError: Command ‘[’/Applications/Slicer.app/Contents/bin/…/bin/PythonSlicer’, ‘/Applications/Slicer.app/Contents/lib/Python/bin/TotalSegmentator’, ‘-i’, ‘/private/var/folders/yg/g0dyz18s69dcy2q5jm2tgf340000gn/T/Slicer-francesco/\_\_SlicerTemp\_\_2022-12-17\_15+59+32.173/total-segmentator-input.nii’, ‘-o’, ‘/private/var/folders/yg/g0dyz18s69dcy2q5jm2tgf340000gn/T/Slicer-francesco/\_\_SlicerTemp\_\_2022-12-17\_15+59+32.173/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 1.

I have already tried the workarounds suggested in previous posts, including the terminal command “%localappdata%\NA-MIC\Slicer 5.2.1\bin\PythonSlicer.EXE” -m pip install torch torchvision torchaudio --force-reinstall" and the command “%localappdata%\na-mic\Slicer 5.2.1\bin\PythonSlicer.exe” -m pip install git+https://github.com/wasserth/TotalSegmentator.git --no-deps. However, I always get the error.  
I am working with Slicer 5.2.1 on macOS 11.4.

Thank you very much for the support!

---

<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:** [December 17, 2022, 4:00pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/12 "2022-12-17T16:00:59Z")

</div>

> [@FraRizzetto](#):
>
> I have already tried the workarounds suggested in previous posts

Those commands were not all for fixing issues but for diagnosing issues. If you executed those then they may have messed up your environment. For figuring out what’s wrong on your system, please remove Slicer, reinstall from scratch, run the segmentation on a Slicer sample data set, and provide here the content of the textbox under the Apply button.

---

<div class="post-metadata">

**Author:** ![FraRizzetto](https://avatars.discourse-cdn.com/v4/letter/f/49beb7/32.png) [@FraRizzetto](https://discourse.slicer.org/u/FraRizzetto)\
**Post date:** [December 17, 2022, 5:06pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/13 "2022-12-17T17:06:55Z")

</div>

I removed Slicer, reinstalled it and the TotalSegmentator extension, and tried it (fast mode) on a Slicer sample data. This time it asked me for updating PyTorch, then it ran smoothly performing the segmentations. Simple but effective advice. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [February 20, 2023, 1:23pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/14 "2023-02-20T13:23:17Z")

</div>

may the weights pre-downloaded by googledrive or somewhere else. Use this plugin downing weights would be terriable for me .cause I can’t download the weights file because of some ssl or network error.

---

<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:** [February 20, 2023, 5:10pm UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/15 "2023-02-20T17:10:30Z")

</div>

Have you really tried it yet?  
What were the configuration, data, machine, and network, what did you expect to happen, and what did not work?  
Can you provide a log from the TotalSegmentator extension output textbox?

Please avoid posting the same problem in different threads.  
Thank you.

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [February 21, 2023, 5:36am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/16 "2023-02-21T05:36:11Z")

</div>

Sorry for submitting duplicate questions many times.  
here is the logs

```auto
Downloading pretrained weights for Task 251 (~230MB) ...
Traceback (most recent call last):
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\urllib3\connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\urllib3\util\connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\socket.py", line 954, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\urllib3\connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\urllib3\connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\urllib3\connection.py", line 309, in connect
    conn = self._new_conn()
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\urllib3\connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x00000287DC4D9D60>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\requests\adapters.py", line 489, in send
    resp = conn.urlopen(
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "C:\Users\someone\AppData\Local\NA-MIC\Slicer 5.3.0-2023-01-13\lib\Python\Lib\site-packages\urllib3\util\retry.py", line 446, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='zenodo.org', port=443): Max retries exceeded with url: /record/6802342/files/Task251_TotalSegmentator_part1_organs_1139subj.zip?download=1 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000287DC4D9D60>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed'))

```

---

<div class="post-metadata">

**Author:** ![zhang\_ming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhang_ming/32/15790_2.png) [@zhang\_ming](https://discourse.slicer.org/u/zhang_ming)\
**Post date:** [February 21, 2023, 5:41am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/17 "2023-02-21T05:41:17Z")

</div>

Sorry for submitting duplicate questions many times again  
the questions are following:

1. can I load weights manually, without using slicer to download weights in case of bad network situation
2. can I use my own trained weight and model to infer the segmentation with your code framework  
thank you

---

<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:** [February 21, 2023, 6:19am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/18 "2023-02-21T06:19:00Z")

</div>

Thanks for the details. Please allow some time for checking this out with the developer of TotalSegmentator and on our own systems.

---

<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:** [February 21, 2023, 8:44am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/19 "2023-02-21T08:44:57Z")

</div>

Just tested this with a fresh 3D Slicer 5.3.0.  
PyTorch and TotalSegmentator installed fine with no problems.

Please understand that the TotalSegmentator extension wraps the program for ease of use in 3D Slicer, and the original code is maintained [here](https://github.com/wasserth/TotalSegmentator).  
Your problem indicates a maybe regional network issue during access to Zenodo and similar problems have [already been reported](https://github.com/wasserth/TotalSegmentator/issues/70) in the TotalSegmentator issue tracker on GitHub.

Please try installing Slicer and TS on a different machine or in a different network.

---

<div class="post-metadata">

**Author:** ![wasserth](https://avatars.discourse-cdn.com/v4/letter/w/ee7513/32.png) [@wasserth](https://discourse.slicer.org/u/wasserth)\
**Post date:** [February 21, 2023, 9:26am UTC](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755/20 "2023-02-21T09:26:30Z")

</div>

You can download the weights manually and put them in the folder where 3D Slicer needs them. @lassoan can tell you where the weights are stored for the TotalSegmentator 3D Slicer extension.

The links to the weights can be seen here:

> <https://github.com/wasserth/TotalSegmentator/blob/master/totalsegmentator/libs.py#L75>

You could also replace those weights by your own trained weights. But you might easily run into problems doing this. You should be familiar with python when you do this.

[Next page](https://discourse.slicer.org/t/totalsegmentator-error-at-first-run-command-python-scripts-totalsegmentator-returned-non-zero-exit-status-120/26755.md?page=2)
