1
votes

I compiled VTK 7.0 (6.3 has the same effect) over cmake with following params:

-LIBRARY_OUTPUT_PATH:PATH="" -CMAKE_INSTALL_PREFIX:PATH="/usr/local" -VTK_ENABLE_VTKPYTHON:BOOL="1" -Module_vtkPython:BOOL="1" - -VTK_Group_Qt:BOOL="1" -CMAKE_OBJCOPY:FILEPATH="/usr/bin/objcopy" -VTK_RENDERING_BACKEND:STRING="OpenGL2" -VTK_INSTALL_PYTHON_MODULE_DIR:PATH="/usr/local/lib/python2.7/site-packages" -DVTK_EGL_DEVICE_INDEX:STRING="0" -VTK_WRAP_PYTHON:BOOL="1" -Module_vtkGUISupportQtOpenGL:BOOL="1" 

Now i can find the binary "vtkpython" at /usr/local/bin .

Good news:

I am allowed to enter python shell with the command "vtkpython" out of this directory (/usr/local/bin) with all the needed vtk bindings.

markovich@markovich-desktop:~$ cd /usr/local/bin/
markovich@markovich-desktop:/usr/local/bin$ vtkpython
vtk version 7.0.0
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
>>> vtk
<module 'vtk' from '/usr/local/lib/python2.7/site-packages/vtk/__init__.py'>
>>> 

Thats a bit irritating because i am expecting to run my default python environement and the vtk bindings are available.

so the bad news:

if I type python in my shell or vtkpython from another location on my system the shell says "no modulen named vtk found" on calling import vtk .

markovich@markovich-desktop:~$ vtkpython 
vtk version 7.0.0
Python 2.7.10 (default, Oct 14 2015, 16:09:02) 
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named vtk
>>> 

Question 1: Maybe I missed something in the make configuration ? Question 2: If I take the actual status (which is somehow working): Is it possible integrate the "vtkpython" bindings in my default python environment? If I am not totally wrong. The binding is correctly loaded out of my python2.7 path like you can see in the terminal:

<module 'vtk' from '/usr/local/lib/python2.7/site-packages/vtk/__init__.py'>

So how can I add this module to be loaded in Python environment ? oO

Thanks in Advance!!

1

1 Answers

0
votes

Since loading vtkpython clearly shows that you have the module available somewhere on your system, you should be able to add the location of the vtk module to your PYTHONPATH variable.

Find where the vtk module is installed (try /usr/local/lib/python2.7/site-packages, you should see a /vtk folder). If you're unsure, you could try to find it in vtkpython with

import vtk
import imp
imp.find_module('vtk')

You can check what paths are stored in PYTHONPATH by entering in terminal:

echo $PYTHONPATH

(In my install, it was empty by default.)

Then you can add the vtk folder location to your PYTHONPATH in terminal:

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages

Check if vtk is availabe:

$ python
>>> import vtk

If it works, you can add the export... line above into your ~/.bashrc or ~/.profile (as appropriate per your distro installation) to permanently load the option in PYTHONPATH.