RanRag
RanRag

Reputation: 49567

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.

Upvotes: 18

Views: 12430

Answers (10)

Guangming Mao
Guangming Mao

Reputation: 775

I just use python2.7.3 on windows-64bits and I met the problem. I solved it by using an unoffical pyopengl package. From the artical, it seems offical package doesn't support 64bits-windows. http://codeyarns.com/2012/04/27/pyopengl-installation-notes-for-windows/

Upvotes: 0

vrplumber
vrplumber

Reputation: 166

This appears to be a bug in the PyOpenGL win32 installer. It is supposed to copy over the DLLS directory from the source package (.zip) but fails to do so in my tests. This should be addressed in PyOpenGL itself, and I will do so for the next beta.

In the meantime, you can copy the OpenGL/DLLS directory from the PyOpenGL 3.1.0b2 source .zip into your site-packages/OpenGL directory to install GLUT and GLE DLLs without needing to install them into your system directories.

Upvotes: 0

Karthik Hegde
Karthik Hegde

Reputation: 183

I had similar problem with python 2.7 64 bit windows. Install the pyOpenGL package from http://www.lfd.uci.edu/~gohlke/pythonlibs/ . Many thanks to Christopher Gohlke for maintaining this !!

Upvotes: 1

wliment
wliment

Reputation: 128

in linux os you should install freeglut3 in ubuntu 12.04 :

 sudo apt-get install freeglut3

Upvotes: 5

Rabih Kodeih
Rabih Kodeih

Reputation: 9521

Same exact problem was happening with me. I am using Python 2.7 on windows xp 32-bits.

Solution:

Just download glut-3.7.6-bin.zip from http://user.xmission.com/~nate/glut.html, unzip, place glut32.dll in C:\windows\system32 and you should be OK.

Upvotes: 4

Not a privileged user
Not a privileged user

Reputation: 963

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.

Upvotes: 7

craGon
craGon

Reputation: 41

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/

Upvotes: 4

adastra
adastra

Reputation: 131

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.

Upvotes: 13

RanRag
RanRag

Reputation: 49567

The problem was with my PyOpenGL installation. Earlier I installed it using easy_install.

So, as @Ferdinand suggested that there seems to be something wrong with your pyopengl installation.

I did a clean install using python setup.py install and it worked.

Upvotes: 1

user1016274
user1016274

Reputation: 4209

glutInit() expects 2 arguments, first an int as the number of command line arguments, then a list (of arguments).
glutInit(len(sys.argv),sys.argv) should do as there's no argc in module sys.

Upvotes: 4

Related Questions