Slicer-Python Packages Use and Install



I downloaded and installed the 3D-Slicer nightly built on a window 64bit machine.

I tried to install the scipy whl using pip, but got a window error [Error 5] Access in denied: …Slicer 4.7.0\Lib\Python\Lib\site-packages\scipy

I also tried pip.main([‘install’,‘scipy’]), but got a failed building wheel for scipy feedback.
Downloading the scipy wheel, then install doesn’t work either.

Does anyone know how to fix that?

Please also see attached


(Jean Christophe Fillion Robin) #5
  1. Even if we manage to install the wheel, there is a chance it doesn’t work at all. Scipy is a binary wheel, it includes compiled code.

  2. That said, since running pip install attempt to update packages located in C:\Program Files\Slicer ..., try to run Slicer as administrator.


I am sorry. How do I run Slicer as an administrator? Thanks!


I tried this
Slicer.exe --launch …\python-install\bin\pip.exe install name-of-pure-python-wheel
Seems like Slicer started to load, but then nothing happened.
Also, is the python-install/bin folder supposed to be inside the Slicer directory? I am not able to find it nor the pip.exe
Thanks so much!

(Jean Christophe Fillion Robin) #8

To run as admin, you need to do right click -> run as admin

Other since you installed Slicer, there is no pip exe.

(Andras Lasso) #9

I’ve tried this on the latest nightly version and it all works well for me!

  1. Start Slicer as administrator: in the start menu, instead of left-click on the Slicer icon, use right-click, then select More... and Run as Administrator.

  2. Install a package by using pip. For example, installing of requests package:

Enter this into the Python interactor:

import pip
pip.main(['install', 'requests'])

The package is successfully downloaded and installed:

Collecting requests
  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
Collecting idna<2.7,>=2.5 (from requests)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
Collecting urllib3<1.23,>=1.21.1 (from requests)
  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
Collecting certifi>=2017.4.17 (from requests)
  Downloading certifi-2017.7.27.1-py2.py3-none-any.whl (349kB)
Collecting chardet<3.1.0,>=3.0.2 (from requests)
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
Installing collected packages: idna, urllib3, certifi, chardet, requests
  Found existing installation: chardet 2.3.0
    Uninstalling chardet-2.3.0:
      Successfully uninstalled chardet-2.3.0
Successfully installed certifi-2017.7.27.1 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22

Dependent packages are updated, therefore before using the installed requests package, you need to restart Slicer (you can use the restart() command in the Python console).

Requests: HTTP for Humans
Error when installing scikit-image via Python Interactor
(Jean Christophe Fillion Robin) #10

Exactly. For pure python packages, that will work great.



Thank you very much for all the help!

While the installation worked well for some packages (e.g. PIL and matplotlib wheels), it still doesn’t work for “scipy”, “sckimage”, etc. Does anyone know what happened? Thank you!

  • I did uninstall numpy and installed numpy+mkl since scipy complained numpy didn’t have mkl.

In particular, I get the following error,

path=r"C:\Program Files\Slicer 4.7.0-2017-09-05\packages\scipy-0.19.1-cp27-cp27m-win_amd64.whl"
>>> pip.main(['install',path])
Processing c:\program files\slicer 4.7.0-2017-09-05\packages\scipy-0.19.1-cp27-cp27m-win_amd64.whl
Requirement already satisfied: numpy>=1.8.2 in c:\program files\slicer 4.7.0-2017-09-05\lib\python\lib\site-packages\numpy-1.13.1-py2.7-win-amd64.egg (from scipy==0.19.1)
Traceback (most recent call last):
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\", line 215, in main
status =, args)
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\commands\", line 335, in run
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\", line 749, in build
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\req\", line 380, in prepare_files
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\req\", line 666, in _prepare_file
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\site-packages\pip\utils\", line 48, in check_dist_requires_python
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\email\", line 177, in feed
File "C:\Program Files\Slicer 4.7.0-2017-09-05\lib\Python\Lib\email\", line 99, in push
parts = data.splitlines(True)
AttributeError: 'NoneType' object has no attribute 'splitlines'


I am trying to install scikit-image with

./Slicer --launch ./bin/python-real -c “import pip; pip.main([‘install’, ‘scikit-image’])”

In the install tree I get the error

/usr/bin/gcc-4.6 -pthread -Wall -Wstrict-prototypes -fno-strict-aliasing -fwrapv -g -fPIC -I/Data-work/BuildDirs/Slicer-4.7.0-2017-09-24-linux-amd64/lib/Python/include/python2.7 -c _posixsubprocess.c -o build/temp.linux-x86_64-2.7/_posixsubprocess.o
_posixsubprocess.c:3:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command '/usr/bin/gcc-4.6' failed with exit status 1

(Andras Lasso) #14

Slicer’s pip does not yet support packages that need compilation. To get access to all Python packages, you have to build Slicer with your Python distribution. See some information here:

(Andreas Kleinöder) #15

Hi all,

a quick questions concerning this topic. I am developing with Slicer on Windows and was also trying to install a module with precompiled data, namely pywin32. After some try and error I figured out that pywin32 also uses precompiled data. Since Slicers Python is build with VS2013 but the module has precompiled with VS2008 I assume the runtimes collide here.
My plan was now to build Slicer on my own such that I also have a Python.exe build with VS2013. Afterwards I would go to pywin32 gitlab page and build the module manually as well. Building pywin32 requires the Python.exe file, thats why I need to build Slicer as well.

Could this work?


(Andras Lasso) #16

If you build Slicer according to build instructions and you build the Python package using the same compiler and compiler settings then it should all work. If you need a Python.exe, you can use Slicer’s SlicerPython.exe.

Note that Slicer includes Qt library, which provides access to lots of Windows APIs (and Linux and macOS APIs), so you might be able to do without pywin32.

(Andreas Kleinöder) #17

Thanks! I think you are right and I should use the Qt library. Haven’t thought about this. Anyways it’s good to know that it should work like this.

(Isaiah Norton) #18

If the API is not available in Qt, or you need code to work outside the Slicer environment too, then you could also try pywincffi. That uses the CFFI module, which can construct calls at runtime via ctypes/libffi (in CPython), and avoid the need for dealing with compiled shim libraries.

(saima safdar) #19

WHy pip.main not working for me. I run as administrator even then its not working for me
Python 2.7.13 (default, Aug 31 2018, 23:24:30) [MSC v.1900 64 bit (AMD64)] on win32
AttributeError: ‘module’ object has no attribute ‘main’

(James Butler) #20

Details can be found Pip in nightly build not working

(saima safdar) #21

how did you install matplotlib and other packages you mentioned.
For me scipy is installed like this.
from pip._internal import main as pipmain

Collecting scipy

Downloading (31.5MB)

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)

Installing collected packages: scipy

Successfully installed scipy-1.1.0
>>> pipmain([‘install’,‘scipy’])

Collecting scipy

Downloading (31.5MB)

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)

Installing collected packages: scipy

Successfully installed scipy-1.1.0

>>> pipmain([‘install’,‘scipy’])

Collecting scipy

Downloading (31.5MB)

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)

Installing collected packages: scipy

Successfully installed scipy-1.1.0

(saima safdar) #22

Why I cant install this package


Collecting scikit-fuzzy

Using cached

Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: ‘c:\users\22374464\appdata\local\temp\pip-req-tracker-v9vnky\6fa5e984c9f7c4180f5cbc9dc5bc4378cf0a090dcb740963746419f9’

Rpy2 pip installation fails
(Andras Lasso) #23

See more details in this post - see above.

(saima safdar) #24

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

from pip._internal import main as pipmain

&gt;&gt;&gt; pipmain(['install','scikit-image'])

Collecting scikit-image

Downloading (24.7MB)

Collecting dask[array]&gt;=0.9.0 (from scikit-image)

Downloading (655kB)

Requirement already satisfied: six&gt;=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&gt;=4.3.0 (from scikit-image)

Downloading (1.5MB)

Collecting PyWavelets&gt;=0.4.0 (from scikit-image)

Downloading (4.2MB)

Collecting networkx&gt;=1.8 (from scikit-image)

Downloading (1.6MB)

Collecting cloudpickle&gt;=0.2.1 (from scikit-image)


Requirement already satisfied: numpy&gt;=1.11.0; extra == &quot;array&quot; 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]&gt;=0.9.0-&gt;scikit-image) (1.13.1)

Collecting toolz&gt;=0.7.3; extra == &quot;array&quot; (from dask[array]&gt;=0.9.0-&gt;scikit-image)

Downloading (45kB)

Collecting decorator&gt;=4.1.0 (from networkx&gt;=1.8-&gt;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