<div dir="ltr"><br>I've discovered a minor problem with the VTK python installation (from build) on OSX.  I'm basically having library path issues and I don't know how to bend VTK build-install to fit OSX python or how to bend OSX python to use the default VTK install paths.<br>
<br><br>First, some explanation of the OSX python installation(s).<br><br>The OSX python installation is a framework that's installed into <br><br>/System/Library/Frameworks/Python.framework<br>AND<br>/Library/Frameworks/Python.framework<br>
<br>I'm no expert on python installations for OSX, so I'm puzzled, even confused by the installation "polymorphism".  It get's better.  If you use macports, you can also have an installation somewhere below /opt/local/....  Moreover, each of these installation paths has the capacity for management of multiple versions of python - that's becoming standard fare on most platforms (I think).  So, for example, under /Library/.... there are a bunch of symlinks to manage the current version, eg (under the /System path):<br>
<br>weber-mbp:Python root# ls -l /System/Library/Frameworks/Python.framework/Versions/<br>total 8<br>drwxr-xr-x   7 root  wheel  238 Feb 21  2008 2.3<br>drwxr-xr-x  11 root  wheel  374 Aug 22 17:59 2.5<br>lrwxr-xr-x   1 root  wheel    3 Feb 21  2008 Current -> 2.5<br>
weber-mbp:Python root# <br><br>AND (under the /Library path):<br><br>weber-mbp:Python root# ls -l /Library/Frameworks/Python.framework/<br>total 24<br>lrwxr-xr-x  1 root  admin   24 Aug 29 16:13 Headers -> Versions/Current/Headers<br>
lrwxr-xr-x  1 root  admin   23 Aug 29 16:13 Python -> Versions/Current/Python<br>lrwxr-xr-x  1 root  admin   26 Aug 29 16:13 Resources -> Versions/Current/Resources<br>drwxr-xr-x  4 root  admin  136 Feb 21  2008 Versions<br>
weber-mbp:Python root# ls -l /Library/Frameworks/Python.framework/Versions/<br>total 8<br>drwxrwxr-x  10 admin  admin  340 Feb 21  2008 2.5<br>lrwxr-xr-x   1 root   admin    3 Aug 29 16:13 Current -> 2.5<br><br><br>As far as I can tell, there are no symlinks between these installations to a common path, so they appear to be entirely independent installations.  That's probably to protect the "system" installation from other "library" installations (eg, I downloaded an install package directly from the <a href="http://python.org">python.org</a> site and I think it installs into the /Library path).<br>
<br><br>NOW, the VTK installation script sets the --prefix="/usr/local/" when doing the install.  In my case, the install command was echoed to the screen during 'make install' as follows:<br><br>running cd "/Users/dweber/src/kitware/VTK_build/Wrapping/Python" && /Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 setup.py install --prefix="/usr/local"  2>&1<br>
<br>So this is the only site-package in the /usr/local python path, ie:<br><br>[ dweber@weber-mbp ~/src/kitware/VTK_build ]$ ll /usr/local/lib/python2.5/site-packages/<br>total 4.0K<br>-rw-r--r--  1 root wheel  248 Sep  2 14:42 VTK-5.2.0-py2.5.egg-info<br>
drwxr-xr-x 54 root wheel 1.8K Sep  2 14:42 vtk/<br><br>That is, it seems this is not the default installation path for python modules on OSX.  So, when I started the default python shell and tried to import vtk, it failed with a message about no module found :-(<br>
<br>I then took some care to specify my default python installation for the bash shell (I chose to use the /Library/... path as my default).  I then double checked this setting in the ccmake config and ran the build again.  This time, I noticed that the installation went into /usr/local again.  Then I ran a post-install command as root:<br>
<br># cd <VTK_build_path>/Wrapping/Python/<br># /Library/Frameworks/Python.framework/Versions/Current/bin/python setup.py install 2>&1<br><br>Without the --prefix option for the installation, this installed into the /Library/... path, ie:<br>
<br>/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk<br><br><br>However, despite my attempt to get the module installed in the "right" place, I get this traceback during the import:<br>
<br> dweber@weber-mbp ~/src/kitware/VTK_build ]$ which python<br>/Library/Frameworks/Python.framework/Versions/Current/bin/python<br>[ dweber@weber-mbp ~/src/kitware/VTK_build ]$ <br>[ dweber@weber-mbp ~/src/kitware/VTK_build ]$ python<br>
Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) <br>[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin<br>Type "help", "copyright", "credits" or "license" for more information.<br>
>>> import vtk<br>Traceback (most recent call last):<br>  File "<stdin>", line 1, in <module><br>  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk/__init__.py", line 41, in <module><br>
    from common import *<br>  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk/common.py", line 7, in <module><br>    from libvtkCommonPython import *<br>ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk/libvtkCommonPython.so, 10): Library not loaded: libvtkCommonPythonD.5.2.dylib<br>
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk/libvtkCommonPython.so<br>  Reason: image not found<br>>>> <br><br><br>This is where the libvtkCommon* libs are at:<br>
<br>/usr/local/lib/python2.5/site-packages/vtk/libvtkCommonPython.so<br>/usr/local/lib/vtk-5.2/libvtkCommonPythonD.5.2.0.dylib<br>/usr/local/lib/vtk-5.2/libvtkCommonPythonD.5.2.dylib<br>/usr/local/lib/vtk-5.2/libvtkCommonPythonD.dylib<br>
<br><br>So then I get crazy with symlink hacks like this:<br><br>$ cd /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk<br>### First I verify how to run a for loop to get all the dylib files:<br>
$ for f in *.so; do nf=`basename $f .so`; echo ""; echo $nf; echo `ls -l /usr/local/lib/vtk-5.2/${nf}D.dylib`  ; done<br>### Then I create all the symlinks:<br>$ for f in *.so; do nf=`basename $f .so`; echo ""; echo "${nf}D.dylib"; ln -s /usr/local/lib/vtk-5.2/${nf}D.dylib ${nf}D.dylib  ; done<br>
<br>However, that doesn't work because the symlinks are not specific to the VTK version.... so:<br><br>$ cd /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/vtk<br>$ rm *.dylib<br>$ for f in *.so; do nf=`basename $f .so`; echo ""; echo "${nf}D.dylib";
ln -s /usr/local/lib/vtk-5.2/${nf}D.5.2.dylib ${nf}D.5.2.dylib  ; done<br>
<br>BUT, it still doesn't work....<br><br>As you can see, I'm in OSX library hell with no thread to find my way back out!  (Things are so much easier on Debian - Ubuntu!).<br><br>Any help much appreciated!<br><br>
Thanks, Darren<br><br></div>