[vtkusers] Python Bindings on OSX?

Eric E. Monson emonson at cs.duke.edu
Wed Jul 14 12:13:19 EDT 2010


Hello,

Which version of OS X are you using? Are you using the standard system Python, or is it one you've built yourself?

The .so extension for the libraries in the VTK egg are normal (but you'll have to have someone else explain why it's that and not .dylib). You shouldn't have to create any other symlinks.

It was a little unclear to me, when you are running the setup.py script, are you doing that from the VTK/Wrapping/Python source directory, or your build/Wrapping/Python directory? Mine installs and imports fine if I run "sudo python setup.py install" from the latter, as long as I've built VTK with VTK_USE_RPATH: ON.

(I'm building VTK 5.6 and git head with x86_64 arch on OS X 10.6.4 using the system Python, although I've been able to build the python wrappers fine on other version for the past couple years. I don't think I've tried building i386 with Snow Leopard...)

-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


On Jul 14, 2010, at 11:20 AM, Sensei wrote:

> Hi! I am trying to build VTK with python bindings (I need it for MayaVi), without any success so far.
> 
> My VTK configuration has turned on VTK_WRAP_PYTHON and BUILD_SHARED_LIBS, while the CMAKE_OSX_ARCHITECTURES is set to i386. 
> 
> The first problem is met building it, but searching on the net I find that issuing "chmod 600 Utilities/vtktiff/tif_fax3sm.c" does the trick. And it did. 
> 
> The second problem I found was in the python installation process, since it uses /usr/local also for python:
> 
> <shell>
> Checking .pth file support in /usr/local/lib/python2.6/site-packages/
> error: can't create or remove files in install directory
> 
> The following error occurred while trying to add or remove files in the
> installation directory:
> 
>    [Errno 2] No such file or directory: '/usr/local/lib/python2.6/site-packages/test-easy-install-57720.pth'
> 
> The installation directory you specified (via --install-dir, --prefix, or
> the distutils default setting) was:
> 
>    /usr/local/lib/python2.6/site-packages/
> 
> This directory does not currently exist.  Please create it and try again, or
> choose a different installation directory (using the -d or --install-dir
> option).
> </shell>
> 
> However, running "/usr/bin/python2.6 setup.py install" under VTK/Wrapping/Python (without the --prefix switch), worked for me. Or at least I thought so:
> 
> <shell>
> $ cd Wrapping/Python && /usr/bin/python2.6 setup.py installrunning install
> running bdist_egg
> running egg_info
> creating VTK.egg-info
> ...
> creating 'dist/VTK-5.4.2-py2.6.egg' and adding 'build/bdist.macosx-10.6-universal/egg' to it
> removing 'build/bdist.macosx-10.6-universal/egg' (and everything under it)
> Processing VTK-5.4.2-py2.6.egg
> creating /Library/Python/2.6/site-packages/VTK-5.4.2-py2.6.egg
> Extracting VTK-5.4.2-py2.6.egg to /Library/Python/2.6/site-packages
> Adding VTK 5.4.2 to easy-install.pth file
> 
> Installed /Library/Python/2.6/site-packages/VTK-5.4.2-py2.6.egg
> Processing dependencies for VTK==5.4.2
> Finished processing dependencies for VTK==5.4.2
> </shell>
> 
> The problem is with shared libraries. Trying to start the MayaVi VTK test script, or even trying to import vtk from a python shell, I get the following problem:
> 
> <shell>
> $ python test_vtk.py 
> Testing if Tkinter is available... 
> OK - you have Tkinter
> TclVersion = 8.5, TkVersion = 8.5
> Traceback (most recent call last):
>  File "test_vtk.py", line 210, in <module>
>    test_value_error()
>  File "test_vtk.py", line 178, in test_value_error
>    import vtk
>  File "/Library/Python/2.6/site-packages/VTK-5.4.2-py2.6.egg/vtk/__init__.py", line 41, in <module>
>    from common import *
>  File "/Library/Python/2.6/site-packages/VTK-5.4.2-py2.6.egg/vtk/common.py", line 7, in <module>
>    from libvtkCommonPython import *
> ImportError: dlopen(/Library/Python/2.6/site-packages/VTK-5.4.2-py2.6.egg/vtk/libvtkCommonPython.so, 10): no suitable image found.  Did find:
> 	/Library/Python/2.6/site-packages/VTK-5.4.2-py2.6.egg/vtk/libvtkCommonPython.so: mach-o, but wrong architecture
> </shell>
> 
> This puzzles me for two reasons. First, the suffix is .so instead of the standard .dylib (I created there some symlinks with the dylib suffix, just in case). The second is simple: the architecture seems to be ok to me, although the file type might not be so:
> 
> <shell>
> $ file /Library/Python/2.6/site-packages/VTK-5.4.2-py2.6.egg/vtk/libvtkCommonPython.so
> /Library/Python/2.6/site-packages/VTK-5.4.2-py2.6.egg/vtk/libvtkCommonPython.so: Mach-O bundle i386
> </shell>
> 
> Why do I get this 'wrong architecture' error? Usually, shared libs have as file types "Mach-O universal binary", and not "bundle"...
> 
> Can you walk me out of this?
> 
> Thanks & cheers!
> 
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list