[vtkusers] VTK Python Wrapper and OS X

Glen Lehmann glehmann at imaging.robarts.ca
Thu Dec 18 10:55:41 EST 2003


Yeah, I've ran into that problem before too.  I don't know anything 
about Mayavi so I'll describe the fix in terms of the python install.

When you run 'python setup.py install' from Wrapping/Python it creates 
symlinks to your vtk libs in pythonX.X/site-packages/vtk_python but, by 
default it does not create the link to 
libvtkRenderingPythonTkWidgets.dylib.  So the solution is just to add 
this symlink.

I'm sure the Mayavi fix is very similar.

Cheers,
Glen

Dr. Daniel James White PhD wrote:

> Hi Glen,
>
> Well it half worked....
> the script ran and changed a bunch of stuff,
> and the otool command now gives the desired result
> seems it still can't find the following library:
>
> [daniel:~] dan% pythonw  
> /Applications/MayaVi/MayaVi-1.3.cvs20031023/mayavi
> Traceback (most recent call last):
>   File "/Applications/MayaVi/MayaVi-1.3.cvs20031023/mayavi", line 
> 306,  in ?
>     app = MayaViTkGUI (r)
>   File  "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/site-packages/mayavi/Main.py", line 832, in __init__
>     self.renwin = Misc.RenderWindow.RenderWindow (self.renwin_frame)
>   File  "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/site-packages/mayavi/Misc/RenderWindow.py", line 87, in  
> __init__
>     height=550)
>   File  "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/site-packages/vtk_python/vtk/tk/vtkTkRenderWidget.py", line  
> 65, in __init__
>     vtkLoadPythonTkWidgets(master.tk)
>   File  "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/site-packages/vtk_python/vtk/tk/vtkLoadPythonTkWidgets.py",  
> line 63, in vtkLoadPythonTkWidgets
>     interp.call('load', filename)
> _tkinter.TclError: dyld:  
> /System/Library/Frameworks/Python.framework/Versions/2.3/Resources/ 
> Python.app/Contents/MacOS/Python can't open library:  
> libvtkRenderingPythonTkWidgets.dylib  (No such file or directory, 
> errno  = 2)
>
>
> here are the locations of that library:
>
> [daniel:~] dan% locate libvtkRenderingPythonTkWidgets.dylib
> /Applications/vtksources/VTK/bin/libvtkRenderingPythonTkWidgets.dylib
> /usr/local/lib/vtk/libvtkRenderingPythonTkWidgets.dylib
> [daniel:~] dan%
>
> here is my modified script
> #!/bin/csh
>
> #set BUILD_PREFIX = /Users/glehmann/Stable/VTK-4.2.0/Build/bin
> set BUILD_PREFIX = /Applications/vtksources/VTK/bin
> set INSTALL_PREFIX = /usr/local/lib/vtk
>
> cd ${INSTALL_PREFIX};
>
> set LIBS = `ls *.dylib *.so`;
>
> foreach lib (${LIBS})
>     set baselib = ${INSTALL_PREFIX}/${lib}
>
>     echo "Working on ${baselib}";
>
>     foreach dependentlib (${LIBS})
>     set changelib = ${INSTALL_PREFIX}/${dependentlib};
>     set buildlib = ${BUILD_PREFIX}/${dependentlib};
>
>     echo "... Changing ${buildlib} to ${changelib}";
>
>     install_name_tool -change ${buildlib} ${changelib} -id ${baselib}  
> ${baselib};
>
>     end
> end
>
> any ideas?
> this is a fault if the vtk build process right? If it was fixed in 
> VTK  it wouldn't happen....?
> So I suppose it will get fixed soon?
>
> cheers
>
> Dan
>
>
> On 18 Dec 2003, at 17:23, Glen Lehmann wrote:
>
>> Hello Dan,
>>
>> The problem is the install_names that are associated with the  
>> installed libraries.  Try this;
>>
>> >> cd /usr/local/lib/vtk
>> >> otool -L libvtkCommonPython
>>
>> and you'll see that libvtkCommonPython is linked against the 
>> absolute  path of the original libraries (i.e. the ones in your VTK/bin)
>>
>> Attached is a script I wrote to fix this problem.  You'll need to  
>> modify the BUILD_PREFIX to match your VTK build location and  
>> INSTALL_PREFIX to /usr/local/lib/vtk.  Others have reported that 
>> this  script hasn't worked for them on the first attempt (although it 
>> does  for me) so it may need some massaging.
>>
>> After you run it try running "otool -L" again an you'll see the  
>> libraries are now linked against the ones in /usr/local/lib/vtk.
>>
>> Good Luck,
>> Glen
>>
>> Dr. Daniel James White PhD wrote:
>>
>>> Hi,
>>>
>>> I am using vtk  on os X 10.2 and 10.3 (built on 10.2) recent CVS
>>> cmake from kitware (why get it anywhere else?)
>>> with MacPython (different for 10.2 and 10.3 as panther contains the  
>>> python engine already, but not the extra bits)
>>> and AquaTckTk Batteries included 8.4 most recent.
>>>
>>> I am running the python vtk frontend MayaVi, using native aqua  
>>> interface on OSX
>>> but I have to run it from the VTK/bin
>>> directory or the compiled binaries are not found, even after
>>> make install.
>>>
>>> maybe you are seeing something similar.
>>>
>>> Dan
>>>
>>> On 18 Dec 2003, at 13:25, vtkusers-request at vtk.org wrote:
>>>
>>>> -__--__--
>>>>
>>>> Message: 3
>>>> Date: Wed, 17 Dec 2003 10:06:17 -0800
>>>> From: Jeremy Guralnick <jg at tachyon.net>
>>>> To: <vtkusers at vtk.org>
>>>> Subject: [vtkusers] VTK Python Wrapper and OS X
>>>>
>>>> I've been trying to get the python wrapper to work under OS X  
>>>> (10.2.8)
>>>> without success. Whether I use python or vtkpython I get the  
>>>> following
>>>> error:
>>>>
>>>> Python 2.2.2 (#1, 01/12/03, 07:51:34)
>>>> [GCC Apple cpp-precomp 6.14] on darwin
>>>> Type "help", "copyright", "credits" or "license" for more  
>>>> information.
>>>>
>>>>>>> import vtk
>>>>>>
>>>>>>
>>>> Traceback (most recent call last):
>>>>   File "<stdin>", line 1, in ?
>>>>   File  
>>>> "/Users/jg/Tachyon/Develop/VTK/Wrapping/Python/vtk/__init__.py",  line
>>>> 7, in ?
>>>>     from common import *
>>>>   File  
>>>> "/Users/jg/Tachyon/Develop/VTK/Wrapping/Python/vtk/common.py", line
>>>> 7, in ?
>>>>     from libvtkCommonPython import *
>>>> ImportError: Loaded module does not contain symbol  
>>>> _initlibvtkCommonPython
>>>>
>>>>>>>
>>>>
>>>> I've tracked this down to the file
>>>> ${VTK_DIR}/VTKBuild/Common/vtkCommonPythonInit.cxx, which includes  
>>>> the
>>>> missing reference from above. The problem appears to be that the  
>>>> build
>>>> process does not compile this file (no object file produced) or  
>>>> attempt to
>>>> link it (no link errors). After a build, the "Common" directory  
>>>> contains 301
>>>> ".cxx" files and 463 ".o" files including 150 object files with  
>>>> "Python" in
>>>> the filename, so a system appears to be built with the python  
>>>> wrapper.
>>>>
>>>> Other than python, the system otherwise works fine. I've run 
>>>> several  of the
>>>> C++ and Tcl tests with no problems. I've also tried both VTK 4.2.2  
>>>> and 4.2.1
>>>> with the same result. Other data that might help are:
>>>>
>>>> cmake 1.6.6 from darwinports
>>>> Python 2.2.2 from fink
>>>> Tcl 8.4 from fink
>>>>
>>>> Any help/insight on this problem would be greatly appreciated.
>>>>
>>>> Jeremy
>>>>
>>>>
>>> Dr. Daniel James White BSc. (Hons.) PhD
>>> Cell Biology
>>> Department of biological and environmental science
>>> PO Box  35
>>> University of Jyväskylä
>>> Jyväskylä FIN 40014
>>> Finland
>>> +358 (0)14 260 4183 (work)
>>> +358 (0)414740463 (mob)
>>>
>>> http://www.chalkie.org.uk
>>> dan at chalkie.org.uk
>>> white at cc.jyu.fi
>>>
>>> _______________________________________________
>>> This is the private VTK discussion list. Please keep messages  
>>> on-topic. Check the FAQ at:  <http://public.kitware.com/cgi-bin/vtkfaq>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>
>> <ChangeVTKInstallNames.csh>
>
> Dr. Daniel James White BSc. (Hons.) PhD
> Cell Biology
> Department of biological and environmental science
> PO Box  35
> University of Jyväskylä
> Jyväskylä FIN 40014
> Finland
> +358 (0)14 260 4183 (work)
> +358 (0)414740463 (mob)
>
> http://www.chalkie.org.uk
> dan at chalkie.org.uk
> white at cc.jyu.fi
>
>





More information about the vtkusers mailing list