# Pip installed Python packaged works on PythonSlicer terminal but not on Slicer console

**URL:** <https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596>\
**Category:** Support\
**Tags:** python, pip\
**Created:** [February 9, 2025, 11:40pm UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596 "2025-02-09T23:40:57Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![modenaxe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/modenaxe/32/79405_2.png) [@modenaxe](https://discourse.slicer.org/u/modenaxe)\
**Post date:** [February 9, 2025, 11:40pm UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/1 "2025-02-09T23:40:57Z")

</div>

Hello,  
I would like to install a python wheel not available form Pypi that was built for Python 3.9.10, which is the same version I see on the Slicer Python console. As suggested in various other posts, I am installing the package using pip:

```auto
PythonSlicer.exe -m pip install package.whl

```

After installation I can correctly import the package and use it with the PythonSlicer command line, but if I try to do the same on the Slicer GUI Python Console, Slicer will freeze and crash.  
If there anything specific that I could try to debug this issue? As mentioned, the python version of the wheel matches the PythonSlicer one, but I am not sure if I have to check anything else, e.g. other packages compatibility.  
Thank you,  
Luca

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 9, 2025, 11:47pm UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/2 "2025-02-09T23:47:40Z")

</div>

What are the Python package dependencies for your package? Any specific versions of those packages you require?

This is an issue on Windows? Have you tried any debugging on another platform?

Does your package rely on any other special considerations such as OS environment variables?

---

<div class="post-metadata">

**Author:** ![modenaxe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/modenaxe/32/79405_2.png) [@modenaxe](https://discourse.slicer.org/u/modenaxe)\
**Post date:** [February 10, 2025, 12:03am UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/3 "2025-02-10T00:03:24Z")

</div>

Hi James,  
sorry for the lack of details.  
I am working on Windows 11, the package is a slightly altered version of [opensim](https://github.com/opensim-org/opensim-core), for which I built the libraries and the wheels [here](https://github.com/modenaxe/testBuildOpenSim/actions/runs/13224443598). The dependencies are included in the package, which needs to know where the dynamic libraries are, but I have specified that path as an environment variable.  
Let me know if there is anything else that could be important to know and thank you for the quick reply!  
Luca

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 10, 2025, 3:42am UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/4 "2025-02-10T03:42:05Z")

</div>

Reviewing your whl build output, I suspect something to do with HDF5 which I saw was a dependency in your package.

See the following forum post with a similar issue of crashing within the application, but not when calling PythonSlicer directly:

> [@SlicerCAT error with hdf5](https://discourse.slicer.org/t/slicercat-error-with-hdf5/23408/16):
>
> This is only a problem if an application or library brings its own HDF5 as a shared library, without shared library name or symbol mangling. ITK and VTK behave well - their HDF5 will not clash with anything (other than potentially another ITK and VTK), unless you force using “system” HDF5. If you force ITK or VTK to use "system HDF5 then it is entirely up to you to manage version conflicts. I’ve checked the wheel files of netcdf4 and h5py. netcdf4 behaves well - it links HDF5 staticallly, so…

---

<div class="post-metadata">

**Author:** ![modenaxe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/modenaxe/32/79405_2.png) [@modenaxe](https://discourse.slicer.org/u/modenaxe)\
**Post date:** [February 10, 2025, 8:23am UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/5 "2025-02-10T08:23:28Z")

</div>

Hi James,  
I have built another wheel removing HDF5 and with the minimum amount of dependencies allowed by the main libraries (available [here](https://github.com/modenaxe/testBuildOpenSim/actions/runs/13234782951)) and the issue persists.  
I can smoothly load and use the package using the PythonSlicer console but the Slicer GUI still freezes when I try to do exactly the same using `import opensim`. I have tried few times and in one occasion the GUI was able to load the package and another time the GUI unfreezed with this error:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/2/927d04e85daae10b34edcb8501f8a0bf46e03638.png).  
However, the package dlls are on the system Path variable (and PythonSlicer is finding them), so this is confusing because the outcome from the GUI looks inconsistent.  
Is the GUI Python Console handling the module loading in the same way as PythonSlicer?

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 10, 2025, 12:43pm UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/6 "2025-02-10T12:43:46Z")

</div>

Are you able to build without the ezc3d package? Or if needed are you able to get ezc3d working on its own in Slicer? Last I remember ezc3d’s Python package was only Python 3.10+ compatible and Slicer is using Python 3.9.

One thing to do to get latest help would be to switch from Slicer 5.6.0 to latest Slicer stable 5.8.0.

@jcfr may have other thoughts but I would think there is some issues with this package and the app launcher that sets up the paths for things like the Python libraries to load.

---

<div class="post-metadata">

**Author:** ![modenaxe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/modenaxe/32/79405_2.png) [@modenaxe](https://discourse.slicer.org/u/modenaxe)\
**Post date:** [February 11, 2025, 5:14am UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/7 "2025-02-11T05:14:13Z")

</div>

Hi James, I have now tried with a wheel without ezc3d in Slicer 5.8.0…Again same outcome for both PythonSlicer (smooth loading the module) and Slicer GUI (frozen).  
The new wheel is available [here](https://github.com/modenaxe/testBuildOpenSim/actions/runs/13254251967).

---

<div class="post-metadata">

**Author:** ![modenaxe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/modenaxe/32/79405_2.png) [@modenaxe](https://discourse.slicer.org/u/modenaxe)\
**Post date:** [February 11, 2025, 8:21am UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/8 "2025-02-11T08:21:38Z")

</div>

After a bit more testing I can confirm that when used through PythonSlicer.exe the loaded package works perfectly, which I assume it means that it is installed correctly and there are no incompatibilities. So my hypothesis is that the issue is due to a difference in how the GUI loads the packages compared to PythonSlicer. Is there a way to enforce the same loading behaviour?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [February 11, 2025, 2:37pm UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/9 "2025-02-11T14:37:59Z")

</div>

> So my hypothesis is that the issue is due to a difference in how the GUI loads the packages compared to PythonSlicer.

When importing a package from the _Python Console_ \[1\] within the application, the Python interpreter is embedded in the overall Qt application, inheriting all Qt, VTK, ITK, and other symbols. As @jamesobutler originally suggested, an ABI mismatch is likely causing DLL loading failures.

* * *

1. [https://slicer.readthedocs.io/en/latest/developer\_guide/python\_faq.html#what-is-the-python-console](https://slicer.readthedocs.io/en/latest/developer_guide/python_faq.html#what-is-the-python-console)

---

<div class="post-metadata">

**Author:** ![modenaxe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/modenaxe/32/79405_2.png) [@modenaxe](https://discourse.slicer.org/u/modenaxe)\
**Post date:** [February 12, 2025, 12:10am UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/10 "2025-02-12T00:10:33Z")

</div>

Thank you Jean. This is not a familiar topic for me, I assume ABI is application binary incompatibility. Can this issue be overcome with some workaround? Building Slicer and the package on the same platform for example?

---

<div class="post-metadata">

**Author:** ![aagatti](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aagatti/32/79201_2.png) [@aagatti](https://discourse.slicer.org/u/aagatti)\
**Post date:** [February 17, 2025, 4:12pm UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/11 "2025-02-17T16:12:32Z")

</div>

Luca - I was here to try and debug an extension Im working on… I couldnt help but notice your name, and then that the libraray is opensim! Im keen to see what you’re working on.

---

<div class="post-metadata">

**Author:** ![modenaxe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/modenaxe/32/79405_2.png) [@modenaxe](https://discourse.slicer.org/u/modenaxe)\
**Post date:** [March 21, 2025, 12:02am UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/13 "2025-03-21T00:02:39Z")

</div>

Hi Anthony, I am just learning how to use Slicer and its Python capabilities (and seeing how much I could push it!), the extension system is very clever! Is your extension related to your neural shape model?

---

<div class="post-metadata">

**Author:** ![aagatti](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aagatti/32/79201_2.png) [@aagatti](https://discourse.slicer.org/u/aagatti)\
**Post date:** [March 24, 2025, 5:08am UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/14 "2025-03-24T05:08:19Z")

</div>

Yes, the extensions are awesome - and they are always getting better! I wrote my first extension for T2 mapping way back ([GitHub - gattia/Slicer-T2mapping](https://github.com/gattia/Slicer-T2mapping))… at that point I think you could only use the already installed python libraries, which were pretty basic. Its awesome how it has grown. For this one… I just downloaded the template library, copied by current script into the repository, and told Cursor what I wanted - it handled most of the hard work :D.

The goal of the extension is to deploy our whole pipeline for knee MRI segmentation, quantitative analysis (cartilage thickness, T2), and apply the NSM: [https://www.medrxiv.org/content/10.1101/2025.02.21.25322094v1.full.pdf](https://www.medrxiv.org/content/10.1101/2025.02.21.25322094v1.full.pdf)

But… that might be ambitious. We’ll see how far I can get 😃.

I dont think we’ve met in person. Hopefully we’ll get a chance to connect at ISB - I’ll be co-hosting a shape modeling workshop, and we should touch on neural shape models there too.

---

<div class="post-metadata">

**Author:** ![modenaxe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/modenaxe/32/79405_2.png) [@modenaxe](https://discourse.slicer.org/u/modenaxe)\
**Post date:** [March 27, 2025, 11:13pm UTC](https://discourse.slicer.org/t/pip-installed-python-packaged-works-on-pythonslicer-terminal-but-not-on-slicer-console/41596/15 "2025-03-27T23:13:12Z")

</div>

I was planning to attend the workshop…and looking forward to testing your new extension!
