odd failure when rendering 3D data in Ubuntu 22.04 with VS Code IDE

74 views
Skip to first unread message

Marc Killpack

unread,
Sep 6, 2023, 2:39:38 AM9/6/23
to pyqtgraph
Hi all, 

I'm developing some code to display coordinate frames and links for robot arms for a class I teach on robotics. Myself and a TA used pyqtgraph successfully a few years ago with older versions of Ubuntu (20.04) and pyqtgraph. 

However, recently, when I tried to update the code for students to use with Ubuntu 22.04, Python 3.11, and using the VS code IDE, I get errors on the command line every time I try to render a GLMeshItem object and the display window only shows a blank grid. I thought that the inputs or data types for this object had changed. But the example provided in the library give the same error for any 3D mesh rendering.

I can reproduce a similar error with the basic example in the attached code.  This code gives the following error when I run it: 
  • QSocketNotifier: Can only be used with threads started with QThread
    /usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py:260: RuntimeWarning:
    Traceback (most recent call last):
      File "/home/robotics/robotics_hw_2022/test_sphere_debug.py", line 30, in <module>
        QtWidgets.QApplication.instance().exec_()
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py", line 239, in paintGL
        self.drawItemTree(useItemNames=useItemNames)
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py", line 271, in drawItemTree
        self.drawItemTree(i, useItemNames=useItemNames)
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py", line 260, in drawItemTree
        debug.printExc()
      --- exception caught here ---
      File "/usr/lib/python3/dist-packages/OpenGL/latebind.py", line 43, in __call__
        return self._finalCall( *args, **named )
    TypeError: 'NoneType' object is not callable
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py", line 257, in drawItemTree
        i.paint()
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 177, in paint
        glVertexPointerf(verts)
      File "/usr/lib/python3/dist-packages/OpenGL/latebind.py", line 47, in __call__
        return self._finalCall( *args, **named )
      File "/usr/lib/python3/dist-packages/OpenGL/wrapper.py", line 626, in wrapperCall
        storeValues(
      File "/usr/lib/python3/dist-packages/OpenGL/arrays/arrayhelpers.py", line 156, in __call__
        contextdata.setValue( self.constant, pyArgs[self.pointerIndex] )
      File "/usr/lib/python3/dist-packages/OpenGL/contextdata.py", line 58, in setValue
        context = getContext( context )
      File "/usr/lib/python3/dist-packages/OpenGL/contextdata.py", line 40, in getContext
        raise error.Error(
    OpenGL.error.Error: Attempt to retrieve context when no valid context
      debug.printExc()
    Error while drawing item <pyqtgraph.opengl.items.GLMeshItem.GLMeshItem object at 0x7efd483d1360>.
    /usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py:260: RuntimeWarning:
    Traceback (most recent call last):
      File "/home/robotics/robotics_hw_2022/test_sphere_debug.py", line 30, in <module>
        QtWidgets.QApplication.instance().exec_()
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py", line 239, in paintGL
        self.drawItemTree(useItemNames=useItemNames)
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py", line 271, in drawItemTree
        self.drawItemTree(i, useItemNames=useItemNames)
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py", line 260, in drawItemTree
        debug.printExc()
      --- exception caught here ---
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/GLViewWidget.py", line 257, in drawItemTree
        i.paint()
      File "/usr/lib/python3/dist-packages/pyqtgraph/opengl/items/GLMeshItem.py", line 177, in paint
        glVertexPointerf(verts)
      File "/usr/lib/python3/dist-packages/OpenGL/latebind.py", line 43, in __call__
        return self._finalCall( *args, **named )
      File "/usr/lib/python3/dist-packages/OpenGL/wrapper.py", line 626, in wrapperCall
        storeValues(
      File "/usr/lib/python3/dist-packages/OpenGL/arrays/arrayhelpers.py", line 156, in __call__
        contextdata.setValue( self.constant, pyArgs[self.pointerIndex] )
      File "/usr/lib/python3/dist-packages/OpenGL/contextdata.py", line 58, in setValue
        context = getContext( context )
      File "/usr/lib/python3/dist-packages/OpenGL/contextdata.py", line 40, in getContext
        raise error.Error(
    OpenGL.error.Error: Attempt to retrieve context when no valid context
      debug.printExc()
    Error while drawing item <pyqtgraph.opengl.items.GLMeshItem.GLMeshItem object at 0x7efd483d1360>.
    Error while drawing item <pyqtgraph.opengl.items.GLMeshItem.GLMeshItem object at 0x7efd483d1360>.
A similar type of error happens with the 3D data examples provided in the library when running this code: 
  • import pyqtgraph.examples
    pyqtgraph.examples.run()

This error only seems to happen when running the code from within the VS Code IDE (even if I try to run it from the terminal within VS code). When running it from the normal command line, there's no problem. Any idea why this might be the case? Any suggestions of how to solve it? I have tried changing the python interpreter being used by VS code, but it doesn't make a difference (and it seems to match the version being called from the normal command line anyway). 

Thanks for any pointers or direction. 

Sincerely,
Marc


test_sphere_debug.py
Reply all
Reply to author
Forward
0 new messages