The module works for / usr / bin / python, but not / opt / local / bin / python

I struggled to install the VTK package, and finally it looked as if everything was installed successfully.

When I import vtk , I get an error:

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

What is the default env python that 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 works fine!

How can I make the vtk module work for my python by default?


Why I want to use /opt/local/ python instead of /System/ python:
All my other modules are installed through MacPorts to install /opt/local/ python. Therefore, if I use /opt/local/bin/python to import vtk, I suddenly cannot use matplotlib , scipy , etc.

Why I can not install vtk using MacPorts:
I keep getting errors installing macports vtk --- I sent a trac error but I haven’t heard anything yet.

Thanks!

+4
source share
1 answer

I had this problem this week. The solution with gratitude [1] is to build it yourself from 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. Make sure you set "VTK_WRAP_PYTHON: ON".
  • Press "c" to start the first setup.
  • 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 start the final setup
  • Press 'g' to create make files

     make [sudo] make install 

Depending on which version of OS X you are using, keep in mind that they only support OS X 10.9 with VTK v6.10, which can be cloned from [2].

If you do not want to create it yourself and want to do it all through Macports, the following link may be useful, but I have not tried 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

+3
source

Source: https://habr.com/ru/post/1488773/


All Articles