Issues Related to the Python Environment in 3D Slicer Software

Why does 3D Slicer bundle its own Python environment instead of using a user-configured Python environment? Can we modify settings to make 3D Slicer use a custom Python environment?

Short answer is this: think of slicer as the system, as a system it uses its own system installed python.

Slightly long answer is because it would be impossible to maintain functionality across different oses, python versions, package managers, virtual environments and such, and it would break things.

Slicer application’s Python environment is your “user-configured Python environment”. You can configure it as any other Python environments. As @muratmaga described, it would be impractical for you to set up and maintain a custom Python environment that is compatible with the Slicer application.

However, if you just want to import Slicer as a library into your Python environment and use some Slicer features from there (some widgets, algorithms, etc.) then you will be able to use SlicerLib. It is planned to be released around the end of this year.

Hello,

I am facing a similar issue. I attempted to install the parallelproj package using SlicerPython, but it seems that I cannot install it via pip. I decided to create a virtual environment using conda, but I am unable to run it in 3D Slicer. Do you have any suggestions in this case? I need this package, and the default Python in 3D Slicer does not support conda.

The parallelproj package is not available on PyPI at all. This is a huge red flag telling that its developers have very limited resources or intent for making their software widely available to users. Conda is heavy, opinionated, and does not mix reliably with pip, so it does not help much if the package is available only via conda.

@lukepolson do you have any advice?