4

I've been struggling with installing the VTK package all day, and finally it looked like everything installed successfully.

When I import vtk I get the error:

Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

That's using the default env python which points to /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

If I use /usr/bin/python, which points to /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7/ it seems to work fine!

How can I get the vtk module to work for my default python?


Why I want to use /opt/local/ python instead of /System/ python:
All of my other modules are installed via MacPorts for the /opt/local/ python installation. So if I use /opt/local/bin/python to import vtk, then I suddenly can't use matplotlib, scipy etc.

Why I can't install vtk with MacPorts:
I keep getting errors with the macports vtk installation --- I've submitted a trac error, but haven't heard anything yet.

Thanks!

DilithiumMatrix
  • 17,795
  • 22
  • 77
  • 119
  • Related: http://stackoverflow.com/questions/15678153/homebrew-python-on-mac-os-x-10-8-fatal-python-error-pythreadstate-get-no-cu – DilithiumMatrix Jun 29 '13 at 01:35

1 Answers1

3

Was having this issue myself this week. The solution with thanks to [1] is to build it yourself from the git sources [2].

git clone https://github.com/Kitware/VTK.git VTK
mkdir VTK-build && cd VTK-build
ccmake ../VTK
  • Press 't' for advanced mode. Ensure you've set "VTK_WRAP_PYTHON: ON".
  • Press 'c' to run the first configure.
  • Set PYTHON_EXECUTABLE: /to/your/python (for Macports: /opt/local/bin/python)
  • Set PYTHON_INCLUDE_DIR: /to/your/Python.framework/Headers (for Macports: /opt/local/Library/Frameworks/Python.framework/Headers)
  • Set PYTHON_LIBRARY: /to/your/Python.framework/libpythonx.x.dylib (for Macports: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib)
  • Press 'c' to run final configure
  • Press 'g' to generate make files

    make
    [sudo] make install
    

Depending on which OS X version you're running, keep in mind that they only support OS X 10.9 since VTK v6.10 which can be cloned from [2].

If you don't want to build it yourself and want it all through Macports, the following link may be useful, but I didn't try it: http://trac.macports.org/ticket/19569

[1] http://www.bioimagexd.net/wiki/index.php?title=Build_in_Mac_OSX#Building_VTK

[2] github[dot]com/Kitware/VTK

kitizz
  • 51
  • 1
  • 6