I am trying to run a minimal example with python and vtk which was adapted from this link but with PySide2 instead of Qt4.
This works fine on my windows machine, with any vtk 9.x.x version.
However, on linux I can run this with vtk < 9.1, but with vtk 9.1.0 I get the following error:
Qt: Session management error: None of the authentication protocols specified are supported
2022-05-24 15:40:09.687 ( 0.590s) [ CC1BB740]vtkOpenGLRenderWindow.c:493 ERR| vtkEGLRenderWindow (0x55732a7a9450): GLEW could not be initialized: Missing GL version
Segmentation fault (core dumped)
Any thoughts on why this is happening? Thank you.
Adapted example code:
import sys
import vtk
from PySide2 import QtWidgets
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent = None):
QtWidgets.QMainWindow.__init__(self, parent)
self.frame = QtWidgets.QFrame()
self.vl = QtWidgets.QVBoxLayout()
self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
self.vl.addWidget(self.vtkWidget)
self.ren = vtk.vtkRenderer()
self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
# Create source
source = vtk.vtkSphereSource()
source.SetCenter(0, 0, 0)
source.SetRadius(5.0)
# Create a mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
# Create an actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
self.ren.AddActor(actor)
self.ren.ResetCamera()
self.frame.setLayout(self.vl)
self.setCentralWidget(self.frame)
self.show()
self.iren.Initialize()
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
sys.exit(app.exec_())