Deborah R. Fowler
OpenGL and Python
Updated on March 18
2013 Updated on Jan 6 2018
Updated on April 28 2022
click here for summary table of compiling
Using Python and OpenGL/GLUT on Windows:
You can use OpenGL/freeglut with python! You will need to download pyOpenGL.
Using this site here, scroll down to the version (or search for PyOpenGL). As of 01/06/2018 I have tested this using PyOpenGL-3.1.1-cp27-cp27m-win-amd64.whl and it worked great! (I'm using python 2.7).
UPDATE for PYTHON 3: Thanks to Christoph Gohlke I downloaded PyOpenGL-3.1.6-cp38-cp38-win_amd64.whl and again no issues! (I'm using python 3.8)
To install a whl file open a cmd window, cd to the directory of the whl file and type:
pip install nameOfFile.whl
There are a couple of example files you can use to test from a forum discussion code here and here. (I tested on Windows 10 on my home desktop in IDLE 01/06/2018 and again on Windows 11 on my desktop in IDLE 04/28/2022).
With Python2.7 I had to install freeglut, in the latest version it did not appeared to be needed, but have kept the instructions below just in case.
(Only necessary in Python2.7) You can download the same version of freeglut as you did for C++ and place the files as you did previously. Instructions here.
Why am I not using the official site?
TIP: Do not use the official release of pyOpenGL - this does not work on Windows when I tested in 2.7 - you will need to use the unofficial version. I discovered this the hard way as have other users (https://codeyarns.com/2012/04/27/pyopengl-installation-notes-for-windows/)
The official version will give an error as described below. (I tried the official release version a few years back on two different machines, went through all the top google suggestions and still had):
File "C:\Python27\lib\site-packages\OpenGL\GLUT\special.py", line 324, in glutInit
_base_glutInit( ctypes.byref(count), holder )
TypeError: 'NoneType' object is not callable