# I tried everything to run totalsegmentator pls help

**URL:** <https://discourse.slicer.org/t/i-tried-everything-to-run-totalsegmentator-pls-help/33023>\
**Category:** Support\
**Tags:** totalsegmentator\
**Created:** [November 25, 2023, 6:01pm UTC](https://discourse.slicer.org/t/i-tried-everything-to-run-totalsegmentator-pls-help/33023 "2023-11-25T18:01:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmad\_Yahay](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ahmad_yahay/32/66917_2.png) [@Ahmad\_Yahay](https://discourse.slicer.org/u/Ahmad_Yahay)\
**Post date:** [November 25, 2023, 6:01pm UTC](https://discourse.slicer.org/t/i-tried-everything-to-run-totalsegmentator-pls-help/33023/1 "2023-11-25T18:01:17Z")

</div>

I am having trouble with totalsegmentator, i tried most solution in the fourm but nothing worked. I tried the brevious version with slicer 5.4 and could not make it work, now I tried with slicer 5.5 review and totalsegmentator v2 and still no hope.

Traceback (most recent call last):  
File “C:\Users\ahmad\AppData\Local\slicer.org\Slicer 5.5.0-2023-11-22\bin\Python\slicer\util.py”, line 3253, in tryWithErrorDisplay  
yield  
File “C:/Users/ahmad/AppData/Local/slicer.org/Slicer 5.5.0-2023-11-22/slicer.org/Extensions-32352/TotalSegmentator/lib/Slicer-5.5/qt-scripted-modules/TotalSegmentator.py”, line 292, in onApplyButton  
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),  
File “C:/Users/ahmad/AppData/Local/slicer.org/Slicer 5.5.0-2023-11-22/slicer.org/Extensions-32352/TotalSegmentator/lib/Slicer-5.5/qt-scripted-modules/TotalSegmentator.py”, line 967, in process  
self.logProcessOutput(proc)  
File “C:/Users/ahmad/AppData/Local/slicer.org/Slicer 5.5.0-2023-11-22/slicer.org/Extensions-32352/TotalSegmentator/lib/Slicer-5.5/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/ahmad/AppData/Local/slicer.org/Slicer 5.5.0-2023-11-22/bin/…/bin\PythonSlicer.EXE’, ‘C:\Users\ahmad\AppData\Local\slicer.org\Slicer 5.5.0-2023-11-22\lib\Python\Scripts\TotalSegmentator.exe’, ‘-i’, ‘C:/Users/ahmad/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_٢٠٢٣-١١-٢٤\_٠٦+٠٥+٢٤.٦٥٢/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/ahmad/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_٢٠٢٣-١١-٢٤\_٠٦+٠٥+٢٤.٦٥٢/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’, ‘–device’, ‘cpu’]’ returned non-zero exit status 1.

I also get this error:  
Writing input file to C:/Users/ahmad/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_٢٠٢٣-١١-٢٤\_٠٦+١٤+٣٩.١٦٥/total-segmentator-input.nii

Creating segmentations with TotalSegmentator AI…

Total Segmentator arguments: [‘-i’, ‘C:/Users/ahmad/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_٢٠٢٣-١١-٢٤\_٠٦+١٤+٣٩.١٦٥/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/ahmad/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_٢٠٢٣-١١-٢٤\_٠٦+١٤+٣٩.١٦٥/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’, ‘–device’, ‘cpu’]

**ERROR: The input file or directory does not exist.**

If you use this tool please cite: [https://pubs.rsna.org/doi/10.1148/ryai.230024](https://pubs.rsna.org/doi/10.1148/ryai.230024)

Using ‘fast’ option: resampling to lower resolution (3mm)  
I am using the ct chest sample

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/0/d0f0e2c6b53c7afa701204fae254107e21d50bea.png)

---

<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:** [November 25, 2023, 6:45pm UTC](https://discourse.slicer.org/t/i-tried-everything-to-run-totalsegmentator-pls-help/33023/2 "2023-11-25T18:45:56Z")

</div>

Most likely the issue is that your regional settings in the operating system make the temporary folder name contain special characters. In the short term, you can fix this by changing your date&time settings in your operating system. We’ll try to change the temporary folder generation in TotalSegmentator later.

---

<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:** [November 26, 2023, 8:57am UTC](https://discourse.slicer.org/t/i-tried-everything-to-run-totalsegmentator-pls-help/33023/3 "2023-11-26T08:57:25Z")

</div>

@lassoan Maybe we could use tempfile,

Me

Is there a better way to create an always working unique temp folder in Python ?

ChatGPT

Creating a universally compatible and unique temporary folder in Python can be done using the `tempfile` module, which is part of Python’s standard library. The `tempfile` module is designed to create temporary files and directories in a way that is secure and system-independent. This means it automatically handles the creation of unique directory names and ensures compatibility across different operating systems and file systems.

Here is a simple way to create a unique temporary directory using `tempfile`:

pythonCopy code

```auto
import tempfile
import os

# Create a new temporary directory
with tempfile.TemporaryDirectory() as temp_dir:
    print("Temporary directory created at:", temp_dir)
    # You can use the temporary directory here

# After the 'with' block, the temporary directory and all its contents are automatically deleted
print("Temporary directory and all its contents have been deleted")

```

This code snippet uses the `TemporaryDirectory()` function within a context manager (`with` statement). The temporary directory is automatically created and is guaranteed to be unique. The `with` statement ensures that the directory is cleaned up (deleted) when you are done with it, which is a good practice when dealing with temporary files and directories.

This method is recommended because it is secure, avoids conflicts, and is compatible with all operating systems where Python runs. It eliminates the need for manual handling of file paths, including issues related to character sets or naming conventions.

---

<div class="post-metadata">

**Author:** ![Ahmad\_Yahay](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ahmad_yahay/32/66917_2.png) [@Ahmad\_Yahay](https://discourse.slicer.org/u/Ahmad_Yahay)\
**Post date:** [November 27, 2023, 5:13am UTC](https://discourse.slicer.org/t/i-tried-everything-to-run-totalsegmentator-pls-help/33023/4 "2023-11-27T05:13:19Z")

</div>

So I tried to change the regional setting and that did not work. Now I installed slicer and total segmentator on another PC that has English as system language so the special charecters will not be generated. However. I still can not run it. This is what I get:

Traceback (most recent call last):  
File “C:\Users\Ahmad\AppData\Local\slicer.org\Slicer 5.4.0\bin\Python\slicer\util.py”, line 3146, in tryWithErrorDisplay  
yield  
File “C:/Users/Ahmad/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py”, line 271, in onApplyButton  
self.logic.process(self.ui.inputVolumeSelector.currentNode(), self.ui.outputSegmentationSelector.currentNode(),  
File “C:/Users/Ahmad/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py”, line 785, in process  
self.logProcessOutput(proc)  
File “C:/Users/Ahmad/AppData/Local/slicer.org/Slicer 5.4.0/slicer.org/Extensions-31938/TotalSegmentator/lib/Slicer-5.4/qt-scripted-modules/TotalSegmentator.py”, line 614, in logProcessOutput  
raise CalledProcessError(retcode, proc.args, output=proc.stdout, stderr=proc.stderr)  
subprocess.CalledProcessError: Command ‘[‘C:/Users/Ahmad/AppData/Local/slicer.org/Slicer 5.4.0/bin/…/bin\PythonSlicer.EXE’, ‘C:\Users\Ahmad\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts\TotalSegmentator.exe’, ‘-i’, ‘C:/Users/Ahmad/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2023-11-27\_08+03+30.287/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/Ahmad/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2023-11-27\_08+03+30.287/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]’ returned non-zero exit status 2.

Also this note:  
Total Segmentator arguments: [‘-i’, ‘C:/Users/Ahmad/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2023-11-27\_08+03+30.287/total-segmentator-input.nii’, ‘-o’, ‘C:/Users/Ahmad/AppData/Local/Temp/Slicer/\_\_SlicerTemp\_\_2023-11-27\_08+03+30.287/segmentation’, ‘–ml’, ‘–task’, ‘total’, ‘–fast’]  
C:\Users\Ahmad\AppData\Local\slicer.org\Slicer 5.4.0\bin.\python-real.exe: can’t open file ‘C:\Users\Ahmad\AppData\Local\slicer.org\Slicer 5.4.0\lib\Python\Scripts\TotalSegmentator.exe’: [Errno 2] No such file or directory

I installed pytorch the cpu version since the gpu does not have 7 GB of memory although its Nvidia. and run the the process in fast mode

![2023-11-27 (2)](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/f/af143d1f76be216704ad293a1d0793dcf0d5cf04.png)

---

<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:** [November 27, 2023, 6:23am UTC](https://discourse.slicer.org/t/i-tried-everything-to-run-totalsegmentator-pls-help/33023/5 "2023-11-27T06:23:14Z")

</div>

OK, this is much better! It seems that the remaining issue is this:

> <https://github.com/lassoan/SlicerTotalSegmentator/issues/49>
>
> When I use TotalSegmentator, I encounter the following issues
> !\[1700839166689\](…https://github.com/lassoan/SlicerTotalSegmentator/assets/12394658/0d9a3ca6-12f7-416c-a8c1-8fb1f2bf6767)

The simplest solution would be to upgrade to Slicer-5.6.

We’ll fix TotalSegmentator on Arabic comptuers soon - see progress here:

> <https://github.com/Slicer/Slicer/pull/7430>
>
> qt.QDateTime().currentDateTime().toString(...) may use Arabic numerals on an ope…rating system set to Arabic language. Always specify en-US locale when using when using date in file/folder names to avoid having to work with paths that may contain unicode characters.
> 
> Fixes problem originally reported at:
> https://discourse.slicer.org/t/i-tried-everything-to-run-totalsegmentator-pls-help/33023/3

---

<div class="post-metadata">

**Author:** ![Ahmad\_Yahay](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ahmad_yahay/32/66917_2.png) [@Ahmad\_Yahay](https://discourse.slicer.org/u/Ahmad_Yahay)\
**Post date:** [November 28, 2023, 5:19am UTC](https://discourse.slicer.org/t/i-tried-everything-to-run-totalsegmentator-pls-help/33023/6 "2023-11-28T05:19:07Z")

</div>

Great thank you working fine now. Thanks for your help.
