Python 2.5 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.

I’ve made available my home-baked VTK 5.4 (actually build from a CVS VTK-5-4-1 tag checkout) 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 2005 (8.0) SP1 on Windows XP2 with full Python 2.5 support.  Get the binaries (or my patched source) by going here.  You want the binaries if you want to use VTK from Python.

IMPORTANT: you might have to install the MS VS2005 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.

11 thoughts on “Python 2.5 enabled VTK 5.4 Windows binaries

  1. Dave

    Thanks a lot for these binaries. I’ve been using them for a while, but I’ve recently felt the need to alter/expand on the base actors (such as adding dimension extension lines to vtkLeaderActor2D).

    Can you provide any tips on accessing protected variables of a base class when inheriting and overriding methods (such as RenderOpaqueGeometry in actor classes)?

    Or, is adding additional actors to base vtkActor classes not something that can be done at the Python level?

    Reply
  2. cpbotha Post author

    @Dave:

    That’s a good question. :) We have a number of own small VTK C++ extensions where we can also override base VTK classes, for example vtktudoss.googlecode.com. With the new DRE you can easily add these to the existing VTK Python support (see http://code.google.com/p/devide/wiki/AddingVTKLibsToBinaryDeVIDE ).

    I know another VTK guru that might have another pure-Python approach for deriving new widgets. I’ll get him to look at your comment as well!

    Reply
  3. Peter

    VTK guru here. But not really, because I have no experience with overriding base VTK classes in Python. C++ is your way to go, I guess. If you want access to protected variables it’s just a matter of making a new class that exposes them… Unfortunately, because a pure-Python solution to this problem would be great!

    Reply
  4. Kadir

    Hi there,

    After doing all what you have said above, I still can not import vtk with Python 2.5

    When you say binaries for windows, I understand no build, or make, or cmake necessary, correct?

    All path, pythonpath updates are done, additional .pth file points to VTK (which is already under Python\lib\site-packages), even the vcredist_x86 package installed…

    What could be missing? Where should I start looking at?

    Thanks

    Kadir

    Reply
    1. cpbotha Post author

      That’s correct, no compilation required.

      If it’s not working, there must be something wrong with your environment setup. Double and triple check all your paths. What error messages are you seeing?

      Have you considered trying the DRE (DeVIDE Runtime Environment)? It’s much easier to get going, as it automatically sets the environment up every time. See this youtube clip: http://www.youtube.com/watch?v=xEbYw73y3pM

      Reply
  5. Kadir

    Thanks for the quick response.

    Multiple checks with paths, no chance.

    Simple import error message: ImportError: No module named vtk

    I’ll see what I can do with DRE.

    Kadir

    Reply
  6. Henry Heberle

    Your tips didn’t work for me. So I thought and did this:

    import sys
    sys.path.append(“C:\Program Files\VTK\bin”)
    sys.path.append(“C:\Program Files\VTK\lib\site-packages”)

    Reply
  7. Germán Larraín

    Awesome! Thanks a lot.

    I did have some trouble though. For those not expert (like me), you may enter this line in the python interpreter to solve the PYTHONPATH issues:

    base_dir = 'C:\\VTK-5.4.2-with-python\\'
    sys.path.append(os.path.dirname(base_dir + 'bin\\'))
    sys.path.append(os.path.dirname(base_dir + 'lib\\site-packages\\'))

    Just replace “base_dir” with whatever you used to extract the provided zip file. Remember, use double slashes! And the path to a directory must end with slashes! Silly mistakes that could make you suffer :)

    Good luck

    Reply

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>