cpbotha.net

voices in my head

cpbotha.net random header image

Python 2.6 enabled VTK 5.4 Windows binaries

August 13th, 2009 · 20 Comments · nerd, tech

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.

Related posts:

  1. Python 2.5 enabled VTK 5.2 Windows binaries
  2. Python 2.5 enabled VTK 5.4 Windows binaries
  3. Python-enabled VTK 5.1 and ITK 3.2 Windows binaries
  4. Adding ErrorEvent handlers to all VTK objects in Python
  5. Python IDE wanted, good, cheap and fast. :)

Tags: ···

20 Comments so far ↓

  • Thomas Hansen

    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?

    • cpbotha

      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.

  • herrwald

    Thanks for making your binaries available! A big help at least for me!

  • Delacroix

    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.

  • pierre_j

    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:
    http://blog.kalmbach-software.de/2008/05/03/howto-deploy-vc2008-apps-without-installing-vcredist_x86exe/

    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,

    Pierre

    • cpbotha

      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.

    • cpbotha

      @Pierre:

      I’ve made a new issue in the DeVIDE bug tracker, specifically for DRE. You can star this to be kept up to date.

      http://code.google.com/p/devide/issues/detail?id=166

  • Gib

    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 …
    Thanks
    Gib

    • cpbotha

      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 http://www.vtk.org/pipermail/vtkusers/2009-May/101042.html ?

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

      • Gib

        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.

        • cpbotha

          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?

          • Gib

            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.

      • Gib

        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))
        self.QVTKRenderWidgetCone(page_VTK)
        self.ui.stackedWidget.setCurrentIndex(2)

        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)
        VTKscene.Initialize()
        VTKscene.Start()
        renWin = VTKscene.GetRenderWindow()

        layout.addWidget(VTKscene)
        ren = vtk.vtkRenderer()
        renWin.AddRenderer(ren)

        cone = vtk.vtkConeSource()
        cone.SetResolution(18)
        coneMapper = vtk.vtkPolyDataMapper()
        coneMapper.SetInput(cone.GetOutput())
        coneActor1 = vtk.vtkActor()
        coneActor1.SetMapper(coneMapper)
        coneActor2 = vtk.vtkActor()
        coneActor2.SetMapper(coneMapper)
        ren.AddActor(coneActor1)
        ren.AddActor(coneActor2)

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

    • cpbotha

      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.

Leave a Comment