VTK-Web Server

I am attempting to run VTK as a server, following this guide: http://kitware.github.io/paraviewweb/examples/RemoteRenderer.html#Using-VTK-as-server

I keep receiving the following error:
File “vtk_server.py”, line 33, in
from vtk.web import protocols
File “C:\Users…\AppData\Local\Programs\Python\Python36\lib\site-packages\vtkmodules\web\protocols.py”, line 10, in
from vtk.vtkWebCore import vtkWebApplication, vtkWebInteractionEvent
ImportError: cannot import name ‘vtkWebApplication’

The vtk repo doesn’t seem to contain a vtkWebCore module so i’ve assumed that this folder is the module and added it to my vtkmodules directory: https://github.com/Kitware/VTK/tree/master/Web/Core
Is this correct?

If so, the vtkWebApplication file is c++ and doesn’t seem to have a python wrapper to call it.?

Could someone please help me understand how to get vtk running as a server and on the web?

Many thanks!

All of what you said is mostly correct. I think the module got wrapped but the issue that you are running into is related to some code refactoring in VTK that changed the way it should be imported.

Actually after trying, I run into similar issue. The web module was not turned ON by default.
By doing so, I was able to make things work with the same import line.

You need to do -D VTK_GROUP_ENABLE_Web=WANT to get that module properly produced.

Thanks for the response Sebastien! I’ve installed vtk python via the cmd “pip install vtk”. Where would i input the -D VTK_GROUP_ENABLE_Web=WANT option?

Edit: I created the build following this documentation: https://gitlab.kitware.com/vtk/vtk/-/blob/master/Documentation/dev/build.md using the settings DVTK_WHEEL_BUILD=ON -DVTK_WRAP_PYTHON=ON -D VTK_GROUP_ENABLE_Web=WANT
and followed the additional steps for python setup.

I added the generated python build files to my python C:\Users…\AppData\Local\Programs\Python\Python36\Lib\site-packages directory (not sure if this step is correct?)

I’m getting the following error now:

Traceback (most recent call last):
  File "vtk_server.py", line 33, in <module>
    from vtk.web import protocols
  File "C:\Users\amylo\AppData\Local\Programs\Python\Python36\lib\site-packages\vtkmodules\web\protocols.py", line 10, in <module>
    from vtk.vtkWebCore import vtkWebApplication, vtkWebInteractionEvent
ModuleNotFoundError: No module named 'vtk.vtkWebCore'

The only vtkWebCore file i have is vtkWebCore.cp37-win_amd64.pyd (python extension module) file but it doesn’t seem to recognise it. the Core folder i mentioned earlier didnt get created and if i do the same process of adding it in manually i get the same error as before.

apologies if im missing something simple.

thanks!

I’m not sure what is going on as I never tried to build VTK with VTK_WHEEL_BUILD. @ben.boeckel do you have some idea of what could be going on?

Did you just copy them? That’s certainly not supported unless you do exactly what the wheel does. If you’re specifying a wheel build, why not make the build and use pip install on it?

Would you be able to provide the exact build cmd you use and the steps to setup python?

It seems to always ignore the Web module when i do this as no web directory is created under the python vtkmodules

If you have a build with the wheel flag set and enable the Web modules, it should package them up. If not, where are the Web modules in the build tree in relation to the other moduels that the glob isn’t finding them?