Crash when the render window is called

Hi, I am writing a python program to calculate the curvature of a 3D vtk model and show the result with a colormap. However, every time when I start the render window and the render window interactor, a crash happens. I am wondering how I can solve this problem. Thanks!

More details which might help:

  1. The vtk version I pip installed is 9.2.4, python version is 3.11.5 on Linux.

  2. The code causes crashing:
    iren.Initialize()
    renWin.Render()

  3. The whole code:
    from vtkmodules.vtkCommonCore import vtkLookupTable
    from vtkmodules.vtkFiltersCore import vtkCleanPolyData
    from vtkmodules.vtkFiltersGeneral import vtkCurvatures
    from vtkmodules.vtkFiltersSources import vtkSuperquadricSource
    from vtkmodules.vtkRenderingCore import (
    vtkActor,
    vtkCamera,
    vtkPolyDataMapper,
    vtkRenderWindow,
    vtkRenderWindowInteractor,
    vtkRenderer,
    vtkDataSetMapper,
    )
    import vtkmodules.vtkInteractionStyle
    import vtkmodules.vtkRenderingFreeType
    import vtkmodules.vtkRenderingOpenGL2
    from vtkmodules.vtkIOLegacy import vtkPolyDataReader

Read vtk file

reader = vtkPolyDataReader()
reader.SetFileName(“/mnt/md0/tempFolder/xiao/ICAC/curv/780/780_cal_left_model.vtk”)
reader.Update()

calculate curvature

curve1 = vtkCurvatures()
curve1.SetInputConnection(reader.GetOutputPort())
curve1.SetCurvatureTypeToGaussian()
curve1.Update()

create colormap

lut1 = vtkLookupTable()
lut1.SetNumberOfColors(256)
lut1.SetHueRange(0.15,1.0)
lut1.SetSaturationRange(1.0,1.0)
lut1.SetValueRange(1.0,1.0)
lut1.SetAlphaRange(1.0,1.0)
lut1.SetRange(-20,20)

map the curvature data with colormap

cmapper1 = vtkPolyDataMapper()
cmapper1.SetInputConnection(curve1.GetOutputPort())
cmapper1.SetLookupTable(lut1)
cmapper1.SetUseLookupTableScalarRange(1)

actor

cActor1 = vtkActor()
cActor1.SetMapper(cmapper1)
cActor1.SetPosition(-0.5,0.0,0.0)

Create renderer stuff

ren1 = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

Add the actors to the renderer

ren1.AddActor(cActor1)
ren1.SetBackground(0.5,0.5,0.5)
ren1.ResetCamera()
renWin.SetSize(300,200)

camera

camera = vtkCamera()
ren1.SetActiveCamera(camera)
camera.SetPosition(0.0,2.0,2.1)
camera.SetFocalPoint(0.0,0.0,0.0)
camera.SetViewAngle(30)
ren1.ResetCameraClippingRange()
iren.Initialize()

render the image

prevent the tk window from showing up then start the event loop

renWin.Render()

# — end of script –