sudo apt-get install libvtk5-dev python-vtk
Once you do that, you can run vtkpython and it just works. Unfortunately, the version of VTK in the packages for Ubuntu 10.04 is 5.2. That's a little out of date, and I needed a newer version. Here's how to install VTK 5.6 or newer with Python wrapping enabled:
Make sure CMake is installed:
sudo apt-get install cmake
Download the VTK source from the Downloads page.
Untar it:
tar xvzf vtk-5.6.0.tar.gz
Create an Out-Of-Source build and configure with CMake:
mkdir VTK_BUILD
cd VTK_BUILD
ccmake ../VTK
Make sure you enable python wrapping and set your install prefix to where you want the package to go. The default /usr/local works fine.
sudo make -j 8 install
(the -j 8 for make just makes the build process parallel assuming you've got the processors for it)
You now have VTK installed. Congrats! if you try to run vtkpython though, you'll get an error:
vtkpython: error while loading shared libraries: libvtksys.so.5.6: cannot open shared object file: No such file or directory
To fix this, append these lines to your .bash_profile, .bashrc, or .profile file in your home directory:
# add vtk paths
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/vtk-5.6"
PYTHONPATH="$PYTHONPATH:/usr/local/lib/vtk-5.6"
You'll need to reset your terminal now.
That sets up your library and python paths for the vtkpython executable. To test this, you can run
brandt@amaterasu:~/work$ vtkpython
vtk version 5.6.0
Python 2.6.5 (r265:79063, Apr 16 2010, 14:15:55)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from vtk import *
>>> renderer = vtkRenderer()
>>>
If you got that far, your installation works!
I still get,
ReplyDeletevtkpython: error while loading shared libraries: libvtksys.so.5.6: cannot open shared object file: No such file or directory
after setting bash profile,....
what do you suggest?
I had a similar error.
ReplyDeleteFirst make sure that /usr/local/lib/vtk-5.6 is the right path, in my case it was vtk-5.8 so I needed to change that.
Modified the .bashrc so that it was this instead:
# add vtk paths
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/vtk-5.6"
PYTHONPATH="$PYTHONPATH:/usr/local/lib/vtk-5.6"
Export LD_LIBRARY_PATH
Export PYTHONPATH
cheers,
ReplyDeletebtw, kaze no taiyou mean 'sun of the wind' ;)
Thanks a lot. That is really helpful:)
ReplyDeleteIn ipython, input "import vtk"
ReplyDeleteImportError: No module named vtk
Hi,
ReplyDeleteI can make this step : ccmake ../VTK
I have this error:
CMake Error: The source directory "/home/afnan/Tlchargements/VTK" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.