Difference between revisions of "Documentation/Labs/SlicerCondaIntegration"
(→Mac) |
m (→Mac) |
||
Line 54: | Line 54: | ||
Expected in: /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/python-miniconda/lib/libsqlite3.dylib | Expected in: /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/python-miniconda/lib/libsqlite3.dylib | ||
in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData | in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData | ||
− | |||
− | |||
dyld: Symbol not found: _sqlite3_intarray_bind | dyld: Symbol not found: _sqlite3_intarray_bind | ||
Referenced from: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData | Referenced from: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData |
Revision as of 00:58, 11 February 2015
Home < Documentation < Labs < SlicerCondaIntegrationSlicer 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.
Before attempting to use the whole Anaconda package, the first approach has been to use Miniconda, which is a reduced version of Anaconda.
Note: the platform used is MacOSX 10.9.5 with XCode 6
Contents
Compile Slicer against miniconda
Mac
- First approach: install Miniconda manually and then build Slicer against it
Assuming that we already installed Miniconda in the default folder ({HOME}/miniconda), we could build Slicer against it:
cmake -DCMAKE_BUILD_TYPE:STRING=Debug \ -DQT_QMAKE_EXECUTABLE:FILEPATH=/usr/bin/qmake \ -DPYTHON_EXECUTABLE:FILEPATH=${HOME}/miniconda/bin/python \ -DPYTHON_INCLUDE_DIR:PATH=${HOME}/miniconda/include/python2.7 \ -DPYTHON_LIBRARY:FILEPATH=${HOME}/miniconda/lib/libpython2.7.dylib \ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9 \ -DCMAKE_OSX_SYSROOT:FILEPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk \ -DSlicer_BUILD_CLI:BOOL=OFF \ -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF \ ../Slicer
At the moment there are also some additional actions to take, like setting some environment variables:
export PYTHONHOME="${HOME}/miniconda/"
It is also possible that you have to set another ones like:
export PYTHONPATH="{HOME}/miniconda/:{HOME}/miniconda/lib/:{HOME}/miniconda/lib/python2.7/site-packages/:{HOME}/miniconda/lib/python2.7/lib-dynload/ :{HOME}/miniconda/lib/python2.7/site-packages/SimpleITK-0.9.0.dev656-py2.7-macosx-10.5-x86_64.egg/SimpleITK/:{HOME}/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/" export DYLD_LIBRARY_PATH="{HOME}/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/SimpleITK-build/lib/:{HOME}/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/"
Besides, it is necessary to fix rpath in the library:
install_name_tool -id {HOME}/miniconda/lib/libpython2.7.dylib {HOME}/miniconda/lib/libpython2.7.dylib Note: the paths have to be absolute, so you want to replace {HOME} for your home folder.
- Second approach: to build a "SlicerPython" using Miniconda
I created a fork from Slicer to implement this approach, packaging Miniconda and installing it in a similar way that SlicerPython is used now. You can download the code in https://github.com/jonieva/Slicer
The only changes are in Superbuild/External_python.cmake file. There is a commented block that you can use to implement the first approach.
However, at the moment I get a build error:
Compiling python scripts: CTKScriptingPythonCore Compiling python scripts: ctkSimplePythonShell Linking CXX shared module ../../bin/CTKCorePythonQt.so 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
NOTE: This problem can be "solved" if we replace the libsqlite3.dylib by a link to the /usr/lib/libsqlite3.dylib library, or even just removing the library from Miniconda.
Also, when I run Slicer.app the program crashes:
Process: Slicer [1333] Path: /Users/USER/*/Slicer.app/Contents/MacOS/./Slicer Identifier: ??? Version: 4.4.0 (4.4.0-2015-02-10) Code Type: X86-64 (Native) Parent Process: Slicer [1332] Responsible: Terminal [205] User ID: 501 Date/Time: 2015-02-10 17:51:57.975 -0500 OS Version: Mac OS X 10.9.5 (13F34) Report Version: 11 Anonymous UUID: F95E6C4D-DD65-A370-437D-3C54CFE11E49 Sleep/Wake UUID: C450E55A-B4B9-4F0B-A350-F80A3FD33CB7 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000098 VM Regions Near 0x98: --> __TEXT 000000010858f000-00000001085bf000 [ 192K] r-x/rwx SM=COW /Users/USER/*/Slicer.app/Contents/MacOS/Slicer Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libpython2.7.dylib 0x000000011eecbd18 subtype_dealloc + 216 1 libPythonQt.dylib 0x000000010cec58d0 PythonQtObjectPtr::~PythonQtObjectPtr() + 96 (PythonQtObjectPtr.cpp:52) 2 libPythonQt.dylib 0x000000010cec58f5 PythonQtObjectPtr::~PythonQtObjectPtr() + 21 (PythonQtObjectPtr.cpp:53) 3 libPythonQt.dylib 0x000000010cde6e5c PythonQtMemberInfo::~PythonQtMemberInfo() + 28 (PythonQtClassInfo.h:45) 4 libPythonQt.dylib 0x000000010cdde605 PythonQtMemberInfo::~PythonQtMemberInfo() + 21 (PythonQtClassInfo.h:45) 5 libPythonQt.dylib 0x000000010cde051c QHashNode<QByteArray, PythonQtMemberInfo>::~QHashNode() + 28 (qhash.h:216) 6 libPythonQt.dylib 0x000000010cde04f5 QHashNode<QByteArray, PythonQtMemberInfo>::~QHashNode() + 21 (qhash.h:216) 7 libPythonQt.dylib 0x000000010cde03dd QHash<QByteArray, PythonQtMemberInfo>::deleteNode2(QHashData::Node*) + 29 (qhash.h:523) 8 QtCore 0x000000011947b73a QHashData::free_helper(void (*)(QHashData::Node*)) + 138 9 libPythonQt.dylib 0x000000010cde0473 QHash<QByteArray, PythonQtMemberInfo>::freeData(QHashData*) + 35 (qhash.h:571) 10 libPythonQt.dylib 0x000000010cde5d7c QHash<QByteArray, PythonQtMemberInfo>::~QHash() + 60 (qhash.h:283) 11 libPythonQt.dylib 0x000000010cdde355 QHash<QByteArray, PythonQtMemberInfo>::~QHash() + 21 (qhash.h:283) 12 libPythonQt.dylib 0x000000010cdd84c4 PythonQtClassInfo::~PythonQtClassInfo() + 500 (PythonQtClassInfo.cpp:78) 13 libPythonQt.dylib 0x000000010cdd87a5 PythonQtClassInfo::~PythonQtClassInfo() + 21 (PythonQtClassInfo.cpp:78) 14 libPythonQt.dylib 0x000000010cdfb2f6 PythonQtPrivate::~PythonQtPrivate() + 230 (PythonQt.cpp:231) 15 libPythonQt.dylib 0x000000010cdfb695 PythonQtPrivate::~PythonQtPrivate() + 21 (PythonQt.cpp:239) 16 libPythonQt.dylib 0x000000010cdfb6b8 PythonQtPrivate::~PythonQtPrivate() + 24 (PythonQt.cpp:224) 17 libPythonQt.dylib 0x000000010cdfb148 PythonQt::~PythonQt() + 72 (PythonQt.cpp:220) 18 libPythonQt.dylib 0x000000010cdfb1b5 PythonQt::~PythonQt() + 21 (PythonQt.cpp:222) 19 libPythonQt.dylib 0x000000010cdfb1d8 PythonQt::~PythonQt() + 24 (PythonQt.cpp:219) 20 libPythonQt.dylib 0x000000010cdfa46d PythonQt::cleanup() + 61 (PythonQt.cpp:155) 21 libCTKScriptingPythonCore.0.1.dylib 0x000000010c4ce7fe ctkAbstractPythonManager::~ctkAbstractPythonManager() + 110 (ctkAbstractPythonManager.cpp:90) 22 libqSlicerBaseQTCore.dylib 0x000000010b8f9409 qSlicerCorePythonManager::~qSlicerCorePythonManager() + 153 (qSlicerCorePythonManager.cxx:59) 23 libqSlicerBaseQTGUI.dylib 0x0000000108a16115 qSlicerPythonManager::~qSlicerPythonManager() + 21 (qSlicerPythonManager.cxx:37) 24 libqSlicerBaseQTGUI.dylib 0x0000000108a16135 qSlicerPythonManager::~qSlicerPythonManager() + 21 (qSlicerPythonManager.cxx:37) 25 libqSlicerBaseQTGUI.dylib 0x0000000108a16158 qSlicerPythonManager::~qSlicerPythonManager() + 24 (qSlicerPythonManager.cxx:33) 26 libqSlicerBaseQTCore.dylib 0x000000010b8a3903 QtSharedPointer::ExternalRefCount<qSlicerCorePythonManager>::deref(QtSharedPointer::ExternalRefCountData*, qSlicerCorePythonManager*) + 115 (qsharedpointer_impl.h:342) 27 libqSlicerBaseQTCore.dylib 0x000000010b8a37d9 void QtSharedPointer::ExternalRefCount<qSlicerCorePythonManager>::internalCopy<qSlicerCorePythonManager>(QtSharedPointer::ExternalRefCount<qSlicerCorePythonManager> const&) + 121 (qsharedpointer_impl.h:413) 28 libqSlicerBaseQTCore.dylib 0x000000010b8a2357 QSharedPointer<qSlicerCorePythonManager>::operator=(QSharedPointer<qSlicerCorePythonManager> const&) + 39 (qsharedpointer_impl.h:484) 29 libqSlicerBaseQTCore.dylib 0x000000010b8a13ad QSharedPointer<qSlicerCorePythonManager>::clear() + 45 (qsharedpointer_impl.h:543) 30 libqSlicerBaseQTCore.dylib 0x000000010b8978b2 qSlicerCoreApplicationPrivate::~qSlicerCoreApplicationPrivate() + 82 (qSlicerCoreApplication.cxx:138) 31 libqSlicerBaseQTGUI.dylib 0x000000010897a595 qSlicerApplicationPrivate::~qSlicerApplicationPrivate() + 261 (qSlicerApplication.cxx:157) 32 libqSlicerBaseQTGUI.dylib 0x000000010897a615 qSlicerApplicationPrivate::~qSlicerApplicationPrivate() + 21 (qSlicerApplication.cxx:157) 33 libqSlicerBaseQTGUI.dylib 0x000000010897a638 qSlicerApplicationPrivate::~qSlicerApplicationPrivate() + 24 (qSlicerApplication.cxx:146) 34 libqSlicerBaseQTCore.dylib 0x000000010b8a457e QScopedPointerDeleter<qSlicerCoreApplicationPrivate>::cleanup(qSlicerCoreApplicationPrivate*) + 46 (qscopedpointer.h:63) 35 libqSlicerBaseQTCore.dylib 0x000000010b8a4537 QScopedPointer<qSlicerCoreApplicationPrivate, QScopedPointerDeleter<qSlicerCoreApplicationPrivate> >::~QScopedPointer() + 39 (qscopedpointer.h:101) 36 libqSlicerBaseQTCore.dylib 0x000000010b8a1c25 QScopedPointer<qSlicerCoreApplicationPrivate, QScopedPointerDeleter<qSlicerCoreApplicationPrivate> >::~QScopedPointer() + 21 (qscopedpointer.h:102) 37 libqSlicerBaseQTCore.dylib 0x000000010b89ccca qSlicerCoreApplication::~qSlicerCoreApplication() + 42 (qSlicerCoreApplication.cxx:670) 38 libqSlicerBaseQTGUI.dylib 0x000000010897cda5 qSlicerApplication::~qSlicerApplication() + 21 (qSlicerApplication.cxx:316) 39 libqSlicerBaseQTGUI.dylib 0x000000010897cdc5 qSlicerApplication::~qSlicerApplication() + 21 (qSlicerApplication.cxx:316) 40 0x00000001085bb989 (anonymous namespace)::SlicerAppMain(int, char**) + 4825 41 0x00000001085ba6a2 main + 34 42 libdyld.dylib 0x00007fff8b4bc5fd start + 1
Linux
The following worked for me (Steve Pieper, 2015-02-04) using ubuntu 13.10 and miniconda 3.8.4-py27_0
cmake \ -DCMAKE_BUILD_TYPE:STRING=Debug \ -DQT_QMAKE_EXECUTABLE:FILEPATH=/usr/bin/qmake \ -DPYTHON_EXECUTABLE:FILEPATH=${HOME}/miniconda/bin/python \ -DPYTHON_INCLUDE_DIR:PATH=${HOME}/miniconda/include/python2.7 \ -DPYTHON_LIBRARY:FILEPATH=${HOME}/miniconda/lib/libpython2.7.so \ -DSlicer_BUILD_CLI:BOOL=OFF \ -DSlicer_USE_PYTHONQT_WITH_TCL:BOOL=OFF \ ../Slicer make -j20 export PYTHONHOME=${USER}/miniconda ./Slicer-build/Slicer
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:
-DSlicer_USE_SYSTEM_NUMPY:BOOL=ON
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 incomplet
Windows
TBD
Compile Slicer using System Python
In order to compare the behaviors, I also compiled another version of Slicer using my System Python:
ccmake -DCMAKE_BUILD_TYPE:STRING=Debug -DQT_QMAKE_EXECUTABLE:FILEPATH=/usr/bin/qmake -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9 -DCMAKE_OSX_SYSROOT:FILEPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -G "Eclipse CDT4 - Unix Makefiles" -DSlicer_USE_SYSTEM_python:BOOL=TRUE ../Slicer
Checking my System Python folder, everything seems to be properly installed.
Common issues in Miniconda and System python
There is a difference between executing Slicer-Superbuild/Slicer-build/bin/Slicer.app and Slicer-Superbuild/Slicer-build/Slicer when I open a Slicer Python console. In the former case, Slicer cannot find some libraries. When I open the console I get:
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-SystemPython/Slicer-build/lib/Slicer-4.4/qt-scripted-modules/SimpleFilters.py", 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/__init__.py", 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/SimpleITK.py", 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/SimpleITK.py", 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/_SimpleITK.so, 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/_SimpleITK.so Reason: image not found
If I run Slicer-Superbuild/Slicer-build/Slicer, everything seems to work fine.
However, in both cases Slicer is loading my System python!
Next step: isolating the Python console problem
Following the advice of Steve Pieper, I tried to replicate the problem just in the CTK Python console, without running Slicer. To do that, I enabled the setting CTK_APP_ctkSimplePythonShell, inside Slicer-Superbuild/CTK-build/CTK-build. I had exactly the same behavior that I had within Slicer.
I tried to set exactly the same settings in my "Slicer Python" version and in my "Miniconda" version, replacing just the settings PYTHON_EXECUTABLE, PYTHON_INCLUDE_DIR and PYTHON_LIBRARY. Still some behavior...
In this process, I found out two things that are different in the "Slicer Python" and "Miniconda":
- If I run otool in my ctkSimplePythonShell, there is a difference in libpython2.7.dylib
~/Projects/BWH/Slicer-Superbuild-Debug/CTK-build/CTK-build/bin$ otool -L ctkSimplePythonShell
ctkSimplePythonShell: /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/CTK-build/CTK-build/bin/libCTKScriptingPythonWidgets.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/CTK-build/CTK-build/bin/libCTKVisualizationVTKCore.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/CTK-build/CTK-build/bin/libCTKWidgets.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/CTK-build/QtTesting-build/libQtTesting.dylib (compatibility version 0.0.0, current version 0.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/CTK-build/CTK-build/bin/libCTKScriptingPythonCore.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkInteraction-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkFiltersHybrid-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkOpenGL-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkImagingHybrid-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkIO-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkTestingRendering-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkRendering-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkFilters-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkalglib-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkverdict-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkftgl-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkfreetype-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 48.0.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 59.0.0) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkImaging-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/CTK-build/CMakeExternals/Install/lib/libPythonQt.dylib (compatibility version 0.0.0, current version 0.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkWrappingPython27Core-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtkCommon-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/python-install/lib/libpython2.7.dylib (compatibility version 0.0.0, current version 0.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/VTKv6-build/lib/libvtksys-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Debug/CTK-build/CTK-build/bin/libCTKCore.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) QtOpenGL.framework/Versions/4/QtOpenGL (compatibility version 4.8.0, current version 4.8.6) QtXmlPatterns.framework/Versions/4/QtXmlPatterns (compatibility version 4.8.0, current version 4.8.6) QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.6) QtXml.framework/Versions/4/QtXml (compatibility version 4.8.0, current version 4.8.6) QtSql.framework/Versions/4/QtSql (compatibility version 4.8.0, current version 4.8.6) QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.8.0, current version 4.8.6) QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.6) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
~/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/CTK-build/CTK-build/bin$ otool -L ctkSimplePythonShell
ctkSimplePythonShell: /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/CTK-build/CTK-build/bin/libCTKScriptingPythonWidgets.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/CTK-build/CTK-build/bin/libCTKVisualizationVTKCore.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/CTK-build/CTK-build/bin/libCTKWidgets.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/CTK-build/QtTesting-build/libQtTesting.dylib (compatibility version 0.0.0, current version 0.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/CTK-build/CTK-build/bin/libCTKScriptingPythonCore.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkInteraction-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkFiltersHybrid-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkOpenGL-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkImagingHybrid-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkIO-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkTestingRendering-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkRendering-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkFilters-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkalglib-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkverdict-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkftgl-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkfreetype-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 48.0.0) /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 59.0.0) /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkImaging-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/CTK-build/CMakeExternals/Install/lib/libPythonQt.dylib (compatibility version 0.0.0, current version 0.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkWrappingPython27Core-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtkCommon-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/libvtksys-6.2.1.dylib (compatibility version 1.0.0, current version 1.0.0) /Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/CTK-build/CTK-build/bin/libCTKCore.0.1.dylib (compatibility version 0.1.0, current version 0.1.0) QtOpenGL.framework/Versions/4/QtOpenGL (compatibility version 4.8.0, current version 4.8.6) QtXmlPatterns.framework/Versions/4/QtXmlPatterns (compatibility version 4.8.0, current version 4.8.6) QtGui.framework/Versions/4/QtGui (compatibility version 4.8.0, current version 4.8.6) QtXml.framework/Versions/4/QtXml (compatibility version 4.8.0, current version 4.8.6) QtSql.framework/Versions/4/QtSql (compatibility version 4.8.0, current version 4.8.6) QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.8.0, current version 4.8.6) QtCore.framework/Versions/4/QtCore (compatibility version 4.8.0, current version 4.8.6) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
So, it looks like there is a problem with the rpath of the library. Even when I tried to copy the python executable and the library itself to the same bin folder where the ctkSimplePython is (Slicer-Superbuild-Conda-Eclipse/CTK-build/CTK-build/bin), I still got the same behavior. Following JC advice (thanks!), I used instal_name_tool to add manually the rpath to libpython2.7.dylib:
install_name_tool -id /Users/Jorge/miniconda/lib/libpython2.7.dylib /Users/Jorge/miniconda/lib/libpython2.7.dylib
Voila! Now we can rebuild and the ctkSimplePythonShell will use the correct Python! However, we will have to set up some environment variables in order than all the libraries are found. I tried some of the most important and checked that they were properly loaded in the Python console, but we will need the same ones that we are adding when building the current "SlicerPython":
export PYTHONHOME="/Users/Jorge/miniconda/" export PYTHONPATH="/Users/Jorge/miniconda/:/Users/Jorge/miniconda/lib/:/Users/Jorge/miniconda/lib/python2.7/site-packages/: /Users/Jorge/miniconda/lib/python2.7/lib-dynload/ :/Users/Jorge/miniconda/lib/python2.7/site-packages/SimpleITK-0.9.0.dev656-py2.7-macosx-10.5-x86_64.egg/SimpleITK/ :/Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/" export DYLD_LIBRARY_PATH="/Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/SimpleITK-build/lib/ :/Users/Jorge/Projects/BWH/Slicer-Superbuild-Conda-Eclipse/VTKv6-build/lib/"
I also checked that the Python console works inside Slicer, as long as I launch the Slicer binary from a terminal that has all these environment variables initialized.