I’m following this very easy guide in order to make my first steps into PyOpenGL.
I installed
pip install PyOpenGL PyOpenGL_accelerate
, all good.I tested the installation through the test code:
import OpenGL.GL import OpenGL.GLUT import OpenGL.GLU print(“Imports successful!”) # If you see this printed to the console then installation was successful
all good
I now run this script:
from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * w,h= 500,500 def square(): glBegin(GL_QUADS) glVertex2f(100, 100) glVertex2f(200, 100) glVertex2f(200, 200) glVertex2f(100, 200) glEnd() def iterate(): glViewport(0, 0, 500, 500) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0.0, 500, 0.0, 500, 0.0, 1.0) glMatrixMode (GL_MODELVIEW) glLoadIdentity() def showScreen(): glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity() iterate() glColor3f(1.0, 0.0, 3.0) square() glutSwapBuffers() glutInit() glutInitDisplayMode(GLUT_RGBA) glutInitWindowSize(500, 500) glutInitWindowPosition(0, 0) wind = glutCreateWindow("OpenGL Coding Practice") glutDisplayFunc(showScreen) glutIdleFunc(showScreen) glutMainLoop()
And the error I receive is OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
So i read a few guides online and they point to download the wheel from here. So I go ahead and I download PyOpenGL_accelerate‑3.1.5‑cp38‑cp38‑win_amd64.whl
and PyOpenGL‑3.1.5‑cp38‑cp38‑win_amd64.whl
because I’m running Python 3.8
pip install .PyOpenGL_accelerate-3.1.5-cp39-cp39-win_amd64.whl
returnsPyOpenGL-accelerate is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.
pip install .PyOpenGL_accelerate-3.1.5-cp38-cp38-win_amd64.whl
returnsPyOpenGL-accelerate is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.
How can a so simple guide lead me to a so painful result?
How can I check if Visual C++ 14.0 build tools
is installed. Maybe that is the only step I’m missing?
Advertisement
Answer
The freeglut DLL is missing from the package.
Unistall “PyOpenGL”:
pip uninstall pyopengl
Download the package wheel (e.g.: “PyOpenGL‑3.1.6‑cp311‑cp311‑win_amd64.whl”) from, Unofficial Windows Binaries for Python Extension Packages and install it:
pip install PyOpenGL‑3.1.6‑cp311‑cp311‑win_amd64.whl