# Cannot import SimpleITK in build-in python

**URL:** <https://discourse.slicer.org/t/cannot-import-simpleitk-in-build-in-python/33900>\
**Category:** Support\
**Tags:** python\
**Created:** [January 22, 2024, 7:51am UTC](https://discourse.slicer.org/t/cannot-import-simpleitk-in-build-in-python/33900 "2024-01-22T07:51:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![schcat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/schcat/32/67987_2.png) [@schcat](https://discourse.slicer.org/u/schcat)\
**Post date:** [January 22, 2024, 7:51am UTC](https://discourse.slicer.org/t/cannot-import-simpleitk-in-build-in-python/33900/1 "2024-01-22T07:51:03Z")

</div>

I have a problem. I compiled SlicerCustomAppTemplate, installed SimpleITK in it’s build-in python, and it crashed when I run “import SimpleITK” in python script.

 ![Screenshot from 2024-01-22 15-37-13](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/a/5a310de269105abbed94e76934ede6c320699bc8.png)  
My environment is Ubuntu22.04. I didn’t open the Slicer\_USE\_SimpleITK option when compile Slicer, but install SimpleITK by pip, because I find that there are many things to install when open the Slicer\_USE\_SimpleITK, is it matter?  
 ![Screenshot from 2024-01-22 15-46-57](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/7/274ab6e893b2f6daee8471100baff145178b191a.png)  
I test other version of SimpleITK and it also doesn’t work. SimpleITK can works well in my systems python 3.10.

---

<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:** [January 23, 2024, 11:29pm UTC](https://discourse.slicer.org/t/cannot-import-simpleitk-in-build-in-python/33900/2 "2024-01-23T23:29:56Z")

</div>

If you want to use SimpleITK in Slicer then you need to enable Slicer\_USE\_SimpleITK. If you install some ABI incompatible SimpleITK binaries from PyPI then Slicer will crash.

A special mechanism was implemented for ITK-Python that allows standalone installation from wheels (Slicer’s ITK does not clash with ITK-Python’s ITK), but as far as I know, this mechanism has not been implemented in SimpleITK. If you don’t want to build SimpleITK but you want to use ITK from Python then you can use ITK-Python.

---

<div class="post-metadata">

**Author:** ![schcat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/schcat/32/67987_2.png) [@schcat](https://discourse.slicer.org/u/schcat)\
**Post date:** [January 24, 2024, 1:29am UTC](https://discourse.slicer.org/t/cannot-import-simpleitk-in-build-in-python/33900/3 "2024-01-24T01:29:00Z")

</div>

Thank you! I’m trying to compile with Slicer\_USE\_SimpleITK is ON, and still encountering some difficulties. Perhaps rewrite this part of code with ITK-Python is a good idear.

---

<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:** [January 24, 2024, 4:49am UTC](https://discourse.slicer.org/t/cannot-import-simpleitk-in-build-in-python/33900/4 "2024-01-24T04:49:47Z")

</div>

If you already installed SimpleITK using pip then you may need to uninstall it, as it may interfere with the one that Slicer builds. But switching to ITK-Python could be a good solution, too.

---

<div class="post-metadata">

**Author:** ![schcat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/schcat/32/67987_2.png) [@schcat](https://discourse.slicer.org/u/schcat)\
**Post date:** [January 24, 2024, 7:43am UTC](https://discourse.slicer.org/t/cannot-import-simpleitk-in-build-in-python/33900/5 "2024-01-24T07:43:05Z")

</div>

OK! It was uninstalled. I have turned to ITK-Python, and it works well with Slicer python environment now. Thank you for your help!
