Slicer-Python Packages Use and Install

I tried to install scikit-image but this is what I get

from pip._internal import main as pipmain

>>> pipmain(['install','scikit-image'])

Collecting scikit-image

Downloading (24.7MB)

Collecting dask[array]>=0.9.0 (from scikit-image)

Downloading (655kB)

Requirement already satisfied: six>=1.10.0 in d:\slicer 4.9.0-2018-08-31\lib\python\lib\site-packages (from scikit-image) (1.11.0)

Collecting pillow>=4.3.0 (from scikit-image)

Downloading (1.5MB)

Collecting PyWavelets>=0.4.0 (from scikit-image)

Downloading (4.2MB)

Collecting networkx>=1.8 (from scikit-image)

Downloading (1.6MB)

Collecting cloudpickle>=0.2.1 (from scikit-image)


Requirement already satisfied: numpy>=1.11.0; extra == "array" in d:\slicer 4.9.0-2018-08-31\lib\python\lib\site-packages\numpy-1.13.1-py2.7-win-amd64.egg (from dask[array]>=0.9.0->scikit-image) (1.13.1)

Collecting toolz>=0.7.3; extra == "array" (from dask[array]>=0.9.0->scikit-image)

Downloading (45kB)

Collecting decorator>=4.1.0 (from networkx>=1.8->scikit-image)


Building wheels for collected packages: networkx, toolz

Running bdist_wheel for networkx: started

Running bdist_wheel for networkx: finished with status 'done'

Stored in directory: C:\Users\22374464\AppData\Local\pip\Cache\wheels\44\c0\34\6f98693a554301bdb405f8d65d95bbcd3e50180cbfdd98a94e

Running bdist_wheel for toolz: started

Running bdist_wheel for toolz: finished with status 'done'

Stored in directory: C:\Users\22374464\AppData\Local\pip\Cache\wheels\f4\0c\f6\ce6b2d1aa459ee97cc3c0f82236302bd62d89c86c700219463

Successfully built networkx toolz

Installing collected packages: toolz, dask, pillow, PyWavelets, decorator, networkx, cloudpickle, scikit-image

**The script skivi.exe is installed in 'D:\Slicer 4.9.0-2018-08-31\lib\Python\Scripts' which is not on PATH.**

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed PyWavelets-1.0.0 cloudpickle-0.5.5 dask-0.19.1 decorator-4.3.0 networkx-2.1 pillow-5.2.0 scikit-image-0.14.0 toolz-0.9.0



I was working on jupyter with scipy and suddenly it stoped working. What happened I dont know. it was importing before but not anymore


import scipy



import scipy


Traceback (most recent call last): File "<string>", line 1, in <module> File "D:\Slicer 4.9.0-2018-08-31\lib\Python\Lib\site-packages\scipy\", line 77, in <module> from . import _distributor_init ImportError: cannot import name _distributor_init

I successfully installed scipy used it once but now its not working:

from pip._internal import main as pipmain

>>> pipmain(['install','scipy'])

Requirement already satisfied: scipy in d:\slicer 4.9.0-2018-08-31\lib\python\lib\site-packages (1.1.0)

Requirement already satisfied: numpy>=1.8.2 in d:\slicer 4.9.0-2018-08-31\lib\python\lib\site-packages\numpy-1.13.1-py2.7-win-amd64.egg (from scipy) (1.13.1)


>>> import scipy

Traceback (most recent call last):

File "<console>", line 1, in <module>

File "D:\Slicer 4.9.0-2018-08-31\lib\Python\Lib\site-packages\scipy\", line 77, in <module>

from . import _distributor_init

ImportError: cannot import name _distributor_init

Currently, you cannot import scipy into Slicer’s embedded Python interpreter. You have access to many Python libraries, you can use numpy, you can run a Jupyter kernel in Slicer’s Python interpreter, import native Python libraries, etc. but not import entire scipy.

Probably we can make Slicer’s Python interpreter compatible with all Python packages, including scipy, within 4-6 months.

I need official packages of python. If I switch to ubuntu. will I be able to install any official package? is there anything I cant do in slicer on linux as compared to widows.

I am not sure of switching but without official packages (scipy, scikit-image, skfuzzy etc) I am unable to proceed with my work. Any option if I stay in windows and can still install official packages.

Thank you

Saima Safdar

Thanks to recent developments, you can already use all these official packages on Windows. You need to implement your processing in Python CLI modules. Slicer writes all input data to files, launches your module with the active Python interpreter (it can be any Python on your computer), and when processing is completed read all the outputs. Process data in CLI module is useful anyway, as processing can run in the background, without blocking the user interface.

See White Matter Analysis extension as an example, which uses scipy, multiprocessing, xlrd, cython, joblib, … packages.

Within about 6 months, we plan to migrate Slicer to Python 3 and then we’ll be able to load any binary Python packages directly in Slicer’s interpreter. However, it’ll be still advisable to do most of the processing in Python CLI modules so that they can run in the background, easily interrupted, etc.

Hi Andras,
I could no understand white matter analysis extension. is there a simple example for python cli modules. or do you recommend any workshop which can help me to learn how to develop cli extensions within slicer.

Saima Safdar

A simpler example is PyCLIModule4Test example:

In the executed Python script you can launch an external Python interpreter (Python3, anaconda, etc.), similarly to how it is done here: Subprocess call in Python interpreter results in memory corruption

1 Like

Hi Andras,
Is there any video on how to develop cli modules. I have searched for step by step guide but couldnt found. I am unable to establish links between different files. How to run these files?
I have seen videos for how to make scripted modules in slicer and how to use the build in cli modules.
I am unable to understand the connections between files.
When I create a cli module in slicer is gives me .xml and .cxx files. Do i need to create the .py and place it in this folder.
How to run this module in slicer? as with scripted it appears in the modules section but cli do not appear in the modules section.

Please help


@lassoan, and about using TensorFlow with Slicer in a Windows 10, is it possible now?
What are the steps that i need to take to make it work?


Yes, it works. You can run any Python script in any environment that you have set up on your system as described in my post above.

Hi Andras,

I would like to use the function scipy.optimize.minimize from scipy.

I have tried to install scipy using pip in Slicer 4.8.1 and 4.10.0, but I am not able to install it properly. I get the following error:


I am doing the installation like this:

from pip._internal import main as pipmain

Is there any way I can use scipy.optimize.minimize function is my 3D Slicer module? What about using this function from a Python CLI module?

Thanks for your time,



Hi David,

We will shortly distribute scipy along with Slicer, this should happen by the end of the week.

Thanks for your patience,


This will be great! Is it going to be included in Slicer-4.10.1? If it is not risky/complicated then it probably should.

That’s great JC! Thanks for the info!

I will check it at the end of the week. It would be great if it was included in the nightly build or the stable version.

Hi JC,

Is Scipy already available?



Hi David,

Not yet, I have to tackle a more urgent deadline first. I will resume work on scipy integration afterward.


1 Like

In my case, I tried to add scipy via slicer python interactor (as I did with 4.8.1) but it didn’t work. I added scipy to slicer-4.10 by copy/paste scipy folder from 4.8.1 and it works. e.g.

cp -r  Slicer-4.8.1/lib/Python/lib/python2.7/site-packages/scipy   Slicer-4.10.0/lib/Python/lib/python2.7/site-packages

Python binaries are ABI compatible with Slicer’s bundled Python in Linux but not in Windows. If you use Windows, you need to wait for Jc.

1 Like

Hi, I’m having the same problem when I try to install packages to my computer. I tried the pip way as you described but it did not work for me. No matter what package I try to install, it always report to following errors:
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: ‘/private/var/folders/4m/3zz84kjj0rb8r7twkxksmplw0000gn/T/pip-req-tracker-dVJBGY/39e3ab1dfb11346e7d530d2e1ee1ef3dc8bbf9578e5f497994026cda’
and some times like this: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: ‘/Volumes/Slicer-4.10.0-macosx-amd64/’
I was wondering if this is because I didn’t run slicer as an administrator. I’m using mac and when I right click on the icon, I didn’t see more and run as administrator. Does anyone know to run slicer on mac as an administrator? And does anyone know how to fix this error?
Please help.