# Python code exit abnormally. custom plugin development

**URL:** <https://discourse.slicer.org/t/python-code-exit-abnormally-custom-plugin-development/33404>\
**Category:** Support\
**Tags:** python\
**Created:** [December 15, 2023, 3:57pm UTC](https://discourse.slicer.org/t/python-code-exit-abnormally-custom-plugin-development/33404 "2023-12-15T15:57:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![IVarha](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ivarha/32/66704_2.png) [@IVarha](https://discourse.slicer.org/u/IVarha)\
**Post date:** [December 15, 2023, 3:57pm UTC](https://discourse.slicer.org/t/python-code-exit-abnormally-custom-plugin-development/33404/1 "2023-12-15T15:57:55Z")

</div>

Hello I am developing a plugin for my research and encountering with a problem when I am running certain code. However error is not reproducible when I am running same code on PythonSlicer (built in in slicer). Here I attach code and logs from correct run in slicerpython and slicer error failed  
slicerpython log:

> ```
> *:~$ /home/user/slic_build/python-install/bin/PythonSlicer*
> Python 3.9.10 (main, Dec 12 2023, 14:56:38)
> [GCC 11.4.0] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from brainextractor import BrainExtractor
> >>> import nibabel as nib
> >>> image = nib.load("/tmp/tmp14016ra4/t1.nii.gz")
> >>> vet = BrainExtractor(image)
> >>> vet.run()
> vet.run()
> Running surface deformation...
> Iteration: 999
> Complete.
> 
> ```

SLICER RUN:

> Running surface deformation…  
> error: [/home/user/slic\_build/Slicer-build/bin/./SlicerApp-real] exit abnormally - Report the problem.

---

<div class="post-metadata">

**Author:** ![RafaelPalomar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rafaelpalomar/32/1436_2.png) [@RafaelPalomar](https://discourse.slicer.org/u/RafaelPalomar)\
**Post date:** [December 18, 2023, 6:13am UTC](https://discourse.slicer.org/t/python-code-exit-abnormally-custom-plugin-development/33404/2 "2023-12-18T06:13:37Z")

</div>

@IVarha, did you installed any python packages within the 3D Slicer environment with `pip` (i.e., brainextractor)? Installing certain packages with `pip` may override the version of those packages provided by Slicer, sometimes producing crashes. If you have built your own Slicer, you could try to provide more information using a debugger:

[C++ debugging on GNU/Linux systems — 3D Slicer documentation](https://slicer.readthedocs.io/en/5.6/developer_guide/debugging/linuxcpp.html#c-debugging-on-gnu-linux-systems)

---

<div class="post-metadata">

**Author:** ![IVarha](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ivarha/32/66704_2.png) [@IVarha](https://discourse.slicer.org/u/IVarha)\
**Post date:** [December 19, 2023, 6:59pm UTC](https://discourse.slicer.org/t/python-code-exit-abnormally-custom-plugin-development/33404/3 "2023-12-19T18:59:30Z")

</div>

You are right I installed some other packages through pip. However as I mentioned when I use python which is used in slicer it works. Is C++ debugging my only option?(I use Wsl, therefore not sure it would be easy to install)

---

<div class="post-metadata">

**Author:** ![RafaelPalomar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rafaelpalomar/32/1436_2.png) [@RafaelPalomar](https://discourse.slicer.org/u/RafaelPalomar)\
**Post date:** [December 22, 2023, 6:29am UTC](https://discourse.slicer.org/t/python-code-exit-abnormally-custom-plugin-development/33404/4 "2023-12-22T06:29:04Z")

</div>

@IVarha, package collision is one hypothesis, to get a better picture of the error debugging is the way. I’ve never used WSL, but it seems it is possible:

> [@Slicer can be built and runs well on Windows Subsystem for Linux (WSL2)](https://discourse.slicer.org/t/slicer-can-be-built-and-runs-well-on-windows-subsystem-for-linux-wsl2/16022):
>
> Some information for Windows developers who want to develop/test Slicer on Linux. On current Windows 10 versions, it is very easy to install Linux and run Linux GUI applications such as Slicer, by using Windows Subsystem for Linux (WSL2). Ubuntu 20.04 shows up as an app in Microsoft Store. If you install and run it you get a linux terminal. By copy-pasting 10-20 lines you can install kubuntu desktop and you can connect to it using Windows remote desktop as explained [here](https://www.nextofwindows.com/how-to-enable-wsl2-ubuntu-gui-and-use-rdp-to-remote). Slicer build instruct…

---

<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 22, 2023, 12:11pm UTC](https://discourse.slicer.org/t/python-code-exit-abnormally-custom-plugin-development/33404/5 "2023-12-22T12:11:40Z")

</div>

You can use the [HDBrainExtraction](https://github.com/lassoan/SlicerHDBrainExtraction) extension in Slicer.
