mcfletch / pyopengl

Repository for the PyOpenGL Project
Other
314 stars 97 forks source link

AttributeError: 'NoneType' object has no attribute 'glGetError' #90

Closed jagprog5 closed 1 year ago

jagprog5 commented 1 year ago

Ubuntu 22.04.1 LTS Python 3.10.6 PyOpenGL 3.1.6

I'm getting the following error when trying to use this package. This is a near fresh installation of Ubuntu. Help is appreciated.

Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from OpenGL.GL import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/john/.local/lib/python3.10/site-packages/OpenGL/GL/__init__.py", line 4, in <module>
    from OpenGL.GL.VERSION.GL_1_1 import *
  File "/home/john/.local/lib/python3.10/site-packages/OpenGL/GL/VERSION/GL_1_1.py", line 14, in <module>
    from OpenGL.raw.GL.VERSION.GL_1_1 import *
  File "/home/john/.local/lib/python3.10/site-packages/OpenGL/raw/GL/VERSION/GL_1_1.py", line 7, in <module>
    from OpenGL.raw.GL import _errors
  File "/home/john/.local/lib/python3.10/site-packages/OpenGL/raw/GL/_errors.py", line 4, in <module>
    _error_checker = _ErrorChecker( _p, _p.GL.glGetError )
AttributeError: 'NoneType' object has no attribute 'glGetError'
>>> 

The underlying opengl installation is fine, since the following C++ code works:

#include <GL/glut.h>

void displayMe(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POLYGON);
        glVertex3f(0.5, 0.0, 0.5);
        glVertex3f(0.5, 0.0, 0.0);
        glVertex3f(0.0, 0.5, 0.0);
        glVertex3f(0.0, 0.0, 0.5);
    glEnd();
    glFlush();
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE);
    glutInitWindowSize(400, 300);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Hello world!");
    glutDisplayFunc(displayMe);
    glutMainLoop();
    return 0;
}
g++ temp.cpp -lGL -lglut
smoe commented 1 year ago

Ubuntu likely has the same problem that Debian has. I just fixed this for me on https://github.com/mcfletch/pyopengl/pull/93 If you do not feel like waiting, please try from the command line

cd /usr/lib/x86_64-linux-gnu
sudo ln -s libglut.so.3.12 libglut.so.3

to help pyopengl find that library. And please report if this fixed it for you. You may need to adapt this slightly if Ubuntu happens to ship a different version of libglut than 3.12.0.

sebimarkgraf commented 1 year ago

@smoe I can confirm that this fixed this issue for me.