Hope this may be useful to someone somewhere...it certainly took me a while to figure it out. It should be much more straightforward in Ubuntu, but if XP is unavoidable, try this:
- Download and install the latest version of Python (www.python.org/download/)
- Download and install a free build system such as cmake (www.cmake.org/cmake/resources/software.html
- Download the VTK source files (www.vtk.org/VTK/resources/software.html)
- Download and install activetcl (www.activestate.com/activetcl/downloads). Skip this step if tcl/tk already installed on system.
- If necessary, download and install a C++ development environment such as MS Visual C++ Express (www.microsoft.com/express/Downloads/#2010-Visual-CPP).
- Unpack the VTK source somewhere.
- Make a subdirectory named "build".
- Open ccmake.
- Where it says `Where is the source code', enter the path to the main VTK directory.
- Where it says `Where to build the binaries', enter the path to the new build folder you just created.
- Hit `Configure'.
- Toggle BUILD_SHARED_LIBS on.
Keep VTK_USE_CARBON on.
Do not use VTK_USE_COCOA.
Toggle VTK_USE_HYBRID on.
Toggle VTK_WRAP_PYTHON on. - Configure again. If there are errors, they are most likely requiring you to add a couple of missing entries to the list of variables. You will probably need to add PYTHON_LIBRARY (eg. c:/python27/Lib) and PYTHON_INCLUDE_DIR (eg. c:/python27/include).
- When no errors are returned, hit `Generate'.
- Find the file FindPythonLibs.cmake and check it has the version of python you are using in the list of version numbers.
- From the VTK build folder, locate the .sln file and open in VC++.
- In VC++, set the debug option to `Release' or `ReleaseWithDebug'.
- Build the solution.
Now you should be able to go into your Python IDE (I use Spyder* which is free), or Python shell, and do `from vtk import *;' to start using the VTK library. Simple as that! I will add tutorials as I learn myself, or if you have any tutorials, please send them my way!
*You must have SciPy and NumPy packages installed too.
This procedure also works with Windows 7 and Vista.
ReplyDeleteThanks! this was really a great help. I however did not have the VTK_USE_CARBON or the VTK_USE_HYBRID options show up.
ReplyDeleteok...its not working! I get to 17 and the build fails!.
ReplyDeleteI wonder, did you get any PYTHON_DEBUG_LIBRARY-NOTFOUND notice when u were configuring in cmake?
Sorry I forgot to add that you will need to add PYTHON_LIBRARY (eg. c:/python27/Lib) and PYTHON_INCLUDE_DIR (eg. c:/python27/include) in cmake. Although this procedure woked for me once, it would seem it is incomplete somehow...
ReplyDeleteBut thanks to another blogger, you can download an installer for VTK here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Which is a whole lot more straightforward! (if it works...haven't tried it yet!)