Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyOpenGL TypeError: 'NoneType' object is not callable

I am trying to learn the basics of game programming and I have installed pygame and pyopengl for that.

MyCode:

import sys
import OpenGL

from OpenGL.GL import *     
from OpenGL.GLU import *    
from OpenGL.GLUT import *

def draw():
      glClear(GL_COLOR_BUFFER_BIT)
      glutWireTeapot(0.5)
      glFlush()

glutInit(sys.argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(250, 250)
glutInitWindowPosition(100, 100)
glutCreateWindow("Python OGL Program")
glutDisplayFunc(draw)
glutMainLoop()

draw()

When I run the above code in my command prompt using

python test.py

I get the following error.

Traceback (most recent call last):
  File "test.py", line 13, in <module>
    glutInit(sys.argv)
  File "C:\Python27\lib\site-packages\pyopengl-3.0.2a5-py2.7.egg\OpenGL\GLUT\special.py", line 324, in glutInit
    _base_glutInit( ctypes.byref(count), holder )
TypeError: 'NoneType' object is not callable

I don't understand why I am getting this error. Am I calling glutinit in a wrong way?

I am using Python 2.7.2.

like image 725
RanRag Avatar asked Apr 17 '12 09:04

RanRag


4 Answers

I was using Python 2.7.3 on Windows 7 64-bit and had a problem causing the same symptoms as Noob.

But the above PyOpenGL reinstallation solution did not help me.

I try a longshot - installation of freeglut - and it helped!

I used Windows MSVC 2.8.0 binary package from here and dropped both 32-bit and 64-bit DLLs to my 32-bit (c:\Windows\SysWOW64) and 64-bit (C:\Windows\System32) dirs accordingly.

like image 89
adastra Avatar answered Sep 23 '22 11:09

adastra


I installed PyOpenGL-3.0.2b2 on Python 3.2 using the setup.py install (with administrator privileges), it came out with the same error as the OP. The setup script didn't copy the DLLS folder, so you have to copy it yourself the whole folder \PyOpenGL-3.0.2b2\OpenGL\DLLS.
This worked for me, hope it helps anyone else.

like image 27
Not a privileged user Avatar answered Sep 21 '22 11:09

Not a privileged user


in linux os you should install freeglut3 in ubuntu 12.04 :

 sudo apt-get install freeglut3
like image 5
wliment Avatar answered Sep 25 '22 11:09

wliment


It appears one has to download either glut or freeglut along with pyOpenGL. And most importantly, on my 64-bit Win7 system it only worked once I placed the glut32.dll file in C:\Windows\System (NOT C:\Windows\System32 - placing it in \System32 did not work!)

Here's a link for glut: http://user.xmission.com/~nate/glut.html

And freeglut: http://www.transmissionzero.co.uk/software/freeglut-devel/

like image 4
craGon Avatar answered Sep 23 '22 11:09

craGon