Python 2.6 enabled VTK 5.4 Windows binaries

You can always check my Latest VTK Windows binaries page to make sure you have the latest blog posting and hence the latest binaries.  It also links to the “old” Python 2.5 VTK 5.4.1 binaries.

I’ve made available my home-baked VTK 5.4.2 Windows binaries.  These have the new-and-improved version of my python-exception-patches integrated (more about this in a future post; a serious dead-lock has been fixed and as a side-effect, you can now run multiple VTK pipelines in different threads!) and have been built with Visual Studio 2008 (9.0) SP1 on Windows XP SP3 with full Python 2.6 support.  Get the binaries (or my patched source) from the two links below.  You want the binaries if you want to use VTK from Python.

IMPORTANT: you might have to install the MS VS2008 SP1 vcredist_x86 package (free!) if you want to use these DLLs (thanks Jelle for pointing this out).  This might not be necessary if you already have one or more of the MS development environments installed.

Please leave a comment on this blog posting if you use these or just hate them. It’s almost like postcard-ware, but with blog comments. Please also link to this page and not directly to the download location, thanks!

To use this from Python, you need to add the following to your PATH:

  • d:\opt\VTK\bin

You also need to add all of the above to PYTHONPATH, as well as the following:

  • d:\opt\VTK\lib\site-packages

… where d:\opt is the drive and directory where you unpacked the ZIP file.

Once you’ve done this and logged out and in again, “import vtk” should work at the Python prompt. Shameless plug: you can use my free envedit software to do the environment editing. It beats the default XP editing thingy.

27 thoughts on “Python 2.6 enabled VTK 5.4 Windows binaries”

  1. Hey,
    Thanks for making your binaries available. I’m having a problem where python cant seem to find teh right dll’s though. I have my PYTHONPATH setup correctly, but I think the dll’s were built as debug maybe?

    its complaining e.g. that it cant find vtkCommonPython. there is a file called vtkCommonPythonD.dll in teh bin directory. Does the ‘D’ mean debug, and is that why it cant find the dll?

    Maybe there is an easy fix, other than manually changin the code in the vtk python module?

    1. See the text in my blog post: You need to setup PYTHONPATH *as well as* your PATH. My text explains what goes where.

      vtkCommonPythonD.dll is not debug, it’s the actual code. You’ll see that there’s also a vtkCommonPython.pyd, and that’s actually the Python DLL that links to the *D.dll.

  2. Thanks very much for your binaries! Could you please show me your CMakeCache.txt? I have spent days building VTK-5.4.2 on Windows. My building procedures succeeds, but the Tutorial/Step1 example always runs without showing anything. I guess I may have configured in wrong settings.

  3. Hi Charles!

    I have installed the binaries you propose on a “severly constrained” computer without installing MS VS2008 SP1 vcredist_x86 as you suggest because I simply can’t: not enough rights.

    Well, it seems to work (no python error when typing “omport vtk”).

    However, I tried to see if there was way to retrieve the dlls inside vcredist_x86.
    I didn’t find any, but I found this post commenting how to build binaries in a way so that users do not need vcredist_x86:

    Please, could you consider it for next binaries?
    I thank you in advance for all the users as myseld, with limited rights on the machine.

    Thanks in advance.
    Best regards,


    1. Hi there Pierre,

      Thank you for these suggestions. I have to say that I’m honestly quite scared of Windows DLLs. :) It took me quite a while to figure out the whole SxS business.

      The link you sent is quite a complex procedure. I’ll take a look if there’s not a simpler one for using DLLs that can be shipped together with the DRE in one ZIP file.

  4. Hi cpbotha, I’ve been taking the first steps in using VTK with Python, and have made some progress, but I can’t get QVTKWidget to work (it doesn’t show up in Qt Designer). I received this info about building VTK for Qt:
    “When you’re using CMake (through the GUI) to change compile options, make sure you turn BUILD_SHARED_LIBS to ON, and for the Qt Designer plugin, you need to turn on VTK_USE_QT, and then after another “configure” step, VTK_USE_GUISUPPORT needs to be turned on. ”
    I’d just like to confirm that these are the steps you took. I’m 99% sure that you would have done this, just to be 100% sure …

    1. Dear Gib,

      I’m very sorry to have to disappoint you, but my VTK is built without VTK_USE_QT.

      I don’t use QT due to licensing concerns (PyQT is GPL and PySide is not mature enough yet), so I’ve been focusing on wxPython, which my binaries do support.

      That being said, it DOES seem as if it might be possible to use my VTK with PyQt: Could you take a look at this posting ?

      Please let me know (in these comments) if you manage (or don’t). :)

      1. I’d found that VTK mailing list thread, but it doesn’t seem to help me. That solution relies on being able to insert a QVTKWidget in Qt Designer. I don’t seem to be able to do that. I communicated with Eric Monson, and he gave me the info I quoted about rebuild flags.

        It seems that when VTK is rebuilt as suggested, QVTKWidgetPlugin.dll is created. Copying this into the Designer plugin directory makes it possible to use QVTKWidgets.

        1. Right, it makes sense that you don’t find it in the Designer.

          However, FWIW, you can still use the Qt VTK components programmatically from Python. Is there now way that you can place a placeholder component in Qt Designer, and just replace that with the real deal once the Python code has been generated?

          1. There could well be a way use a placeholder in Designer then build the QVTKWidget programmatically, but I haven’t been able to find it yet. I’ve seen some very suggestive hints, but for me they don’t quite work as advertised. Supposedly a QWidget can be promoted to a QVTKWidget in Designer, but in my case all the steps seem to be OK but the promotion doesn’t occur. What I find puzzling is that the VTK example:
            VTK\Examples\GUI\Qt\SimpleView\uiSimpleView4.ui contains such a promoted QVTKWidget, which is displayed in DEsigner as such. I guess it’s in the ui code, but the associated support is missing from my installation.

      2. Hi there, I have finally got QVTKRenderWindowInteractor working with your VTK build, and it turned out to be very simple (I am just a beginner with Python and Qt). In case someone is interested here is what I did (and thanks!) :

        import vtk
        from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

        # …
        # set up PyQt UI, created with Qt Designer,which includes a
        # QWidget named page_VTK, as the 3rd entry in stackedWidget
        # …
        page_VTK = self.ui.page_VTK
        page_VTK.setMaximumSize(QtCore.QSize(800, 600))

        def QVTKRenderWidgetCone(self,page_VTK):
        “””A simple example that uses the QVTKRenderWindowInteractor class (vtk.qt4).”””

        layout = QtGui.QVBoxLayout(page_VTK)
        # create the widget
        VTKscene = QVTKRenderWindowInteractor(page_VTK)
        renWin = VTKscene.GetRenderWindow()

        ren = vtk.vtkRenderer()

        cone = vtk.vtkConeSource()
        coneMapper = vtk.vtkPolyDataMapper()
        coneActor1 = vtk.vtkActor()
        coneActor2 = vtk.vtkActor()

        coneActor1.SetPosition(2, 0, 1)
        coneActor2.SetPosition(0, 2, 0)
        # show the widget

    2. I just checked the VTK source code in VTK/Wrapping/Python/vtk/qt4 and it you should definitely be able to get the QVTKRenderWindowInteractor working with my VTK binaries (i.e. no VTK_USE_QT) and PyQt.

      1. Yes, QVTKRenderWindowInteractor does work. I can run the demo. But I want to render the VTK imagery embedded within a frame in my PyQt application. This is the step I can’t get to work. If I had QVTKWidgetPlugin.dll it would apparently be straightforward.

  5. Thanks for making these binaries available bru.
    I’m using them for trying out GIS images in 3D. Just need to figure out how to use color and how to change the height values.


  6. Sidenote, to install this on my Ubuntu-box (the VTK and Mayavi packages) took me about 10 min of waiting and one painless ‘sudo apt-get install’ command.
    Mac – compiling the whole day
    Windows – stealing someone else’s binary + environment variables etc. – 50 min.

  7. hi, i tried what you say in here. But i think im doing something wrong or not doing all the steps. I did this in python cmd line:
    import sys

    in order to add the directory to PATH as you said.
    then i went to control panel, system, advanced, environment variables and create PYTHONPATH and give the value of C:\python27\VTK\lib\site-packages. When i try to import vtk it says :”File C:\python27\VTK\lib\site-packages\vtk\ from vtk Common import * ImportError DLL load file” .

    what am i doing wrong here ?

    1. You have to add \python27\VTK\bin also to your system PATH, i.e. via the control panel, else Windows can’t find the DLLs. Adding this to sys.path in Python is not sufficient.

      PYTHONPATH needs to get *both*, i.e.:

  8. Thanks for your answer. I added the other value to my PYTHONPATH and i am still stuck with that error. What else could it be ? I added it just like you said , separated by a semicolon, then i restarted my system.

  9. Thanks for the binaries. The Kitware instructions for Windows installation leave MUCH to be desired.

    BTW, envedit is GREAT!

Leave a Reply

Your email address will not be published. Required fields are marked *