Jul 26, 2009

How to Install VTK for use with Python

I am installing VTK, which I will need to incorporate 3D visualisation in my GUI. I am designing my GUI in Qt, and programming with Python. (Hence, PyQt). To make VTK work with Python, you need to install from binaries, instead of downloading with the windows installer. Feel free to make comments, or ask questions. (I'm not an expert. I am actually a beginner, but I want to document my problems and solutions so that others can be benefited. So feel free to talk here, as it might help others too.)

Download and install:

Download and unzip into a file (we will call this the source file):
VTK(http://www.vtk.org/VTK/resources/software.html): Source: vtk-5.4.2.zip (Don't use the windows installer, because then you can't use Python.)

Then follow these steps:

1. Open the Cmake 2.6 GUI, and type in the path for the source file, and also where you would like to store the binary files.
Source: C:/Qt/vtk-5.4.2 (I have unzipped the source file into this directory called vtk-5.4.2, which is in my 'Qt' folder. Type in the path for your source file.)
Binary: C:/Qt/VTKbin7 (This is an empty folder, into which Cmake will put binaries.)
>Choose Visual Studio 8 2005 as generator
>Turn on these (in the red lines): BUILD_SHARED_LIBS and VTK_WRAP_PYTHON

2. Open Visual Studio;
Open File;
Find the folder where Cmake has put your binaries. E.g. C:/Qt/VTKbin7
Open VTK.sln

3. >Build >Configuration Manager >Active solution configuration
>Choose ‘Release’

4. >Build
>Build Solution
This will take more than an hour.

5. Now you should be able to find ‘vtkpython.exe’ in your bin/release file. E.g. C:/Qt/VTKbin7/bin/release

Now go to Embedding VTK into a PyQt GUI


  1. I think that i have the same problem. I am trying to use VisTrials. As i understand it needs the VTK to be installed. Can you help me with the procedure? i am also beginner!

  2. Hi,

    I did almost all steps listed in this link to install vtk for use with Python.
    Now, I don't know how to embedding vtk into the python and use it with the python shell. I have installed Python 2.7.4.
    After typing the "import vtk" command in the python shell prompt I get the error "...No module named vtk".
    Could someone explain me please what should I do in order to embedding vtk into python and having the "import vtk" command working in the python shell?
    Since I don't use Qt, the last step doen't work in my case.

    Thanks in advance,

    Mário Sandro.

    1. Hi there,
      Thanks for visiting, but sorry I'm no longer working with Python, but good luck with you work!


So, what did you think?