[vtkusers] Python Bindings on OSX?

Sensei senseiwa at gmail.com
Wed Jul 14 11:20:09 EDT 2010


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!












More information about the vtkusers mailing list