vtkRenderWindow Render method on server

vtkRenderWindow Render method on Linux server not working

getting below error

vtkXOpenGLRenderWindow.:464    ERR| vtkXOpenGLRenderWindow (0x55edd2d73ce0): bad X server connection. DISPLAY=

If X is not running you need to use an offscreen version such as OSMesa or EGL.

vtkRenderWindow Render working fine if I run file manually.

But not working with end to end process using celery using APIs.

Does I have to change vtk code to work with OSMesa?

Your code can remain the same, but the VTK library needs to be built with a different rendering backend for your celery use case.

Thanks, for you help.
One last question,

I am using python, can we do this with python?