From Slicer Wiki
Jump to: navigation, search
Home < Documentation < Labs < PythonCondaBuild

Slicer currently builds a custom python distribution from source, but not all useful packages are available. But Anaconda provides a set of binaries that might provide a more comprehensive ecosystem.

Instead of attempting to use the whole Anaconda package, our approach will be to use Miniconda, a reduced version of Anaconda, and (1) install a pre-defined set of packages and (2) provide a way to easily install new ones.

Update 2016-01-22 (Jorge)

After a follow up with JC about this topic, and due to the apparent complexity of this task, it has been decided to make a small survey to have a better idea of which would be the most needed packages for the community from those ones available in Anaconda.

The link to indicate your preferences is:

Update 2015-10-10

We (Kitware) did few experiments where we copied the anaconda numpy and SciPy packages into a Slicer build tree and run the associated tests. The link below summarizes the results.

It turns out that there are a lot of issues with this approach.


Next step: We suggest to continue with the initial approach where Slicer is built against miniconda Python libraries.

Virtual Hackfest: August 24, 9am


Location: Google hangout (connection details will be shared on the Slicer developer list)

What: Work on Slicer and Conda integration

Proposed tasks

  • Review and consolidate contributions of Jorge and Adam Check.svg
  • Implement miniconda external project files as outlined below Check.svg
  • Create a Slicer module providing:
    • (1) scripted interface to install additional conda package
    • (2) UI to provide similar functionality
  • Update extension description format to specify python dependencies that could be installed either at build/package time or at run time.


Compile Slicer against miniconda


Note: the platform used is MacOSX 10.9.5 with XCode 6

 cmake \
 -DSlicer_USE_CONDA_python:BOOL=ON \

The only changes in the source code are in Superbuild/External_python.cmake and in Superbuild/External_NUMPY.cmake files (in the current version Slicer will use Anaconda Numpy). For the sake of testing, the next Python Conda modules are installed by default: numpy, scikit-learn.


  • libsqlite3.dylib library in miniconda has a conflict with CTK:
  Compiling python scripts: CTKScriptingPythonCore
  Compiling python scripts: ctkSimplePythonShell
  Linking CXX shared module ../../bin/
    dyld: Symbol not found: _sqlite3_intarray_bind
  Referenced from: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
  Expected in: /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/python-miniconda/lib/libsqlite3.dylib
    in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
  dyld: Symbol not found: _sqlite3_intarray_bind
    Referenced from: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
    Expected in: /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/python-miniconda/lib/libsqlite3.dylib
  in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
 Workaround: delete or rename the file (there is a hack included in the External_python.cmake file to this end).
  • When running (not the binary file in Slicer-Superbuild-Conda/Slicer-build) the program is not using Miniconda, but the System Python, so it doesn't find the right libraries:
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
>>> Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda/Slicer-build/lib/Slicer-4.4/qt-scripted-modules/", line 3, in <module>
    import SimpleITK as sitk
  File "/Library/Python/2.7/site-packages/SimpleITK-0.9.0.dev656-py2.7-macosx-10.9-intel.egg/SimpleITK/", line 1, in <module>
    from .SimpleITK import *
  File "/Library/Python/2.7/site-packages/SimpleITK-0.9.0.dev656-py2.7-macosx-10.9-intel.egg/SimpleITK/", line 28, in <module>
    _SimpleITK = swig_import_helper()
  File "/Library/Python/2.7/site-packages/SimpleITK-0.9.0.dev656-py2.7-macosx-10.9-intel.egg/SimpleITK/", line 24, in swig_import_helper
    _mod = imp.load_module('_SimpleITK', fp, pathname, description)
ImportError: dlopen(/Library/Python/2.7/site-packages/SimpleITK-0.9.0.dev656-py2.7-macosx-10.9-intel.egg/SimpleITK/, 2): Library not loaded: libSimpleITKBasicFilters12-0.9.1.dylib
  Referenced from: /Library/Python/2.7/site-packages/SimpleITK-0.9.0.dev656-py2.7-macosx-10.9-intel.egg/SimpleITK/
  Reason: image not found

So, in order that the system works, Slicer must be started from a terminal running the file Slicer-Superbuild-Conda/Slicer-build/Slicer


cmake \
  '''-DSlicer_USE_CONDA_python:BOOL=ON''' \

Different approach

2015-02-04 - Steve Pieper

The following worked for me (Steve Pieper, 2015-02-04) using ubuntu 13.10 and miniconda 3.8.4-py27_0

cmake \
  -DPYTHON_EXECUTABLE:FILEPATH=${HOME}/miniconda/bin/python \
  -DPYTHON_INCLUDE_DIR:PATH=${HOME}/miniconda/include/python2.7 \
  -DPYTHON_LIBRARY:FILEPATH=${HOME}/miniconda/lib/  \

make -j20

export PYTHONHOME=${USER}/miniconda


But after it ran there was slicer's build of numpy inside miniconda, so I needed to do this:

bin/conda uninstall numpy
bin/conda install numpy

I tried using this:


but got this error:

-- SuperBuild -         CTKAPPLAUNCHER[OK] (SYSTEM)
CMake Error at SuperBuild/External_CTKAPPLAUNCHER.cmake:21 (message):
  Enabling Slicer_USE_SYSTEM_CTKAPPLAUNCHER is not supported !
Call Stack (most recent call first):
  CMake/ExternalProjectDependency.cmake:561 (include)
  SuperBuild/External_python.cmake:21 (ExternalProject_Include_Dependencies)
  CMake/ExternalProjectDependency.cmake:561 (include)
  SuperBuild/External_VTKv6.cmake:11 (ExternalProject_Include_Dependencies)
  CMake/ExternalProjectDependency.cmake:561 (include)
  SuperBuild/External_teem.cmake:11 (ExternalProject_Include_Dependencies)
  CMake/ExternalProjectDependency.cmake:561 (include)
  CMake/ExternalProjectDependency.cmake:607 (ExternalProject_Include_Dependencies)
  SuperBuild.cmake:320 (ExternalProject_Include_Dependencies)
  CMakeLists.txt:599 (include)

-- Configuring incomplete

2015-03-02 - Jc

2015-03-02(Jc): To simplify even further, using Slicer >= r24007, the following is expected to work. It is not needed to manually remove Numpy.

This is achieved by specifying -DSlicer_USE_SYSTEM_NUMPY:BOOL=1 and also by specifying all dependencies of NUMPY (python, zlib, OpenSSL and CTKAPPLAUNCHER) should not be expected on the system.

Note also that since I built Qt against the latest version of OpenSSL in the 1.0.1 series, I explicitly add -DOPENSSL_DOWNLOAD_VERSION:STRING=1.0.1l


cmake \
  -DPYTHON_INCLUDE_DIR:PATH=${CONDA_ROOT}/miniconda/include/python2.7 \
  -DSlicer_USE_SYSTEM_OpenSSL:BOOL=0 \
  -DSlicer_USE_SYSTEM_zlib:BOOL=0 \
  -DSlicer_USE_SYSTEM_python:BOOL=0 \

nice make -j4


Although the code in should work with Windows too (using the setting Slicer_USE_CONDA_python=ON), it has not been tested at the moment.

Compile Slicer and python 2.7.10 + drop in conda binary packages

Initial experiments


Next steps

Phase 1

Copied from the conclusion of the Developer hangout of March 24th 2015

  • Python conda - next steps:
    • Create External_miniconda.cmake
    • Add a variable named EXTERNAL_PYTHON_NAME that could take two values: python or miniconda
      • In the SuperBuild.cmake, an option named EXTERNAL_PYTHON_NAME could be added. By default, it would be set to "python" but could switch to "miniconda"
    • Projects like External_{CTK, VTK}.cmake would be updated to depend on ${EXTERNAL_PYTHON_NAME}
    • For now, let's consider only the case OpenSSL disabled.

Check.svg See

Phase 2