Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyOpenGL glutInit NullFunctionError

I am running Anaconda Python 2.7 on a Win7 x64 machine and used

pip install PyOpenGL PyOpenGL_accelerate 

at the Anaconda command line to install PyOpenGL.

I have some code (not my own I must confess) that makes use of glutInit

import sys import math import numpy  import OpenGL from OpenGL.GL import * from OpenGL.GLUT import *  import Image  import linkage  # ... a whole load of definitions etc ...  glutInit(sys.argv) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB) glutInitWindowSize(600, 600) glutCreateWindow('linkage') init() initWindow() glutIdleFunc(idle) glutMainLoop() 

I run by entering the following at the command line:

python main.py peaucellier.txt 

But then get the following error (line 371 is the glutInt(sys.argv) line above)

File "C:/Users/Owner/Documents/Python Scripts/linkage/main.py", line 371, in <module> glutInit(sys.argv)  File "C:\Anaconda\lib\site-packages\OpenGL\GLUT\special.py", line 333, in glutInit _base_glutInit( ctypes.byref(count), holder )  File "C:\Anaconda\lib\site-packages\OpenGL\platform\baseplatform.py", line 407, in __call__ self.__name__, self.__name__,  NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling 

I have looked at similar errors posted in this forum but none of the proposed fixes are working which is why I'm asking, what's wrong here?

Is the installation at fault? Are the imports correct?

EDIT: After trying many many fixes for the official release I am now using an unofficial release that works perfectly from Unofficial Windows Binaries for Python Extension Packages

like image 974
DrBwts Avatar asked Nov 02 '14 15:11

DrBwts


Video Answer


2 Answers

According to the link below the problem was with the glut installation rather than pip install. It seems glut files are not part of PyOpenGL or PyOpenGL_accelerate package. You have to download them seperately.

https://stackoverflow.com/a/39181193/7030177

Windows user can use the link below to download glut as mentioned in the given link. ftp://ftp.sgi.com/opengl/glut/glut3.html.old#windows

Linux Users can just install glut using the following command:

sudo apt-get install freeglut3-dev 

Hope this helps :)

like image 191
Shashanka Prajapati Avatar answered Sep 17 '22 19:09

Shashanka Prajapati


After looking around for a solution to a similar problem I ran across this google group that answers the question: https://groups.google.com/forum/#!topic/glumpy-users/aC1NjEHXtEE

There is a problem with OpenGL.GLUT when downloaded as pip from the official source. Uninstall OpenGL using pip, then download OpenGL from http://www.lfd.uci.edu/~gohlke/pythonlibs/

like image 21
user2723240 Avatar answered Sep 21 '22 19:09

user2723240