Building VTK from source in windows for python or 'CameraOrientationWidget'

Hello everyone i hope you’re doing well,

As a newbie, i installed vtk from python using pip install vtk. However i had an error when using cam_orient_manipulator = vtk.vtkCameraOrientationWidget() claiming that vtk has no attribute named vtkCameraOrientationWidget. My question is this call deprecated by now ? i can’t find any other references, whatsoever.

I have then tought that maybe that is a recent feature so i downloaded the source from the website , and compiled it with cMake, checked the configuration for python and build it with visual studio code. ( This operation took me 1 day to figure out). But now i have another error :

Can you please help me figuring out either the first or second error ? Thanks for your assistance !

vtkCameraOrientationWidget() is only in the master. So building VTK is the only way to access it at this stage. Make sure when building VTK that the Python wrapping is also built. After that is done, go to CameraOrientationWidget and copy the Python code. If that runs then your build is Ok. Also please check your paths.

Hello, thank you for you answer.
I have already built vtk with python_wrap. It generates the “.py” files in “C:\vtk\bin\bin\Lib\site-packages” and a folder called “vtkmodules” where there is plenty of “.py” files. I added “C:\vtk\bin\Libe\site-packages” in PYTHONPATH but i still have the error shown above. Thank you!

It looks like the VTK dlls are not being accessed. There is a little script called windows_path.bat in the top level of your build directory. This contains the path settings for VTK. Make sure you add these before running your Python code.

In Python 3.9 the PATH is not searched for DLLs needed by the python modules:

In the VTK master branch, VTK sets the DLL paths in vtkmodules/, but for VTK 9.0 (including 9.0.3), your best bet is to use vtkpython.exe instead of python.exe or py.exe.