Search code examples
pythonerror-handlingpython-2.xpyopengl

Trouble using pyopengl in Python 2.6.6


What I'm trying to do is code a basic OpenGL 2.0 window, when I run the code from a file, it works for the first couple of runs, then it dumps errors. If I run the same exact code from the IDLE GUI, I get a window every time. The following is first a list of added Python 2.6.6 packages, the code and the errors. Am I using any conflicting packages? Am I missing a package? My imports work in the IDLE GUI. Any help would be great!!

Date:   Aug 1, 2011             Time:   03:20:00 AM
This is the listing of packages installed for Python 2.6.6.  
This file was created manually and is meant to be used as a 
reference to show what packages were added in which order

python-2.6.6.msi
setuptools-0.6c11-win32-py26.exe
numpy-1.6.0-win32-superpack-python26.exe
PIL-1.1.7-win32-py26.exe
wxPython2.8-win32-unicode-2.8.12.0-py26.exe
wxPython2.8-win32-docs-demos-2.8.12.0.exe
pyglet-1.1.4.msi
pywin32-216-win32.py32.exe
PyOpenGL-3.0.1.win32.exe
PyOpenGL-accelerate-3.0.1-win32-py26.exe
Pygame-1.9.1-win32-py26.msi
py2exe-0.6.9-win32-py2.6.exe
psyco (using c:\python26\scripts\easy_install psyco)
    #import sys              #redundant(used to  eval errors)
    #import OpenGL           #redundant(used to  eval errors)       
    #import numpy            #redundant(used to  eval errors)

    #From here down is the original code, with gl imports listed as GLUT/GL/GLU
    #Page 26 PyOpenGL.pdf by Stan Blank, Ph.D
    from OpenGL.GL import *     #These 3 imports are called in a layered format
    from OpenGL.GLU import *    #Fron the simplest to the most complex(complete)
    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()
IDLE error listings
Traceback (most recent call last):
  File "C:\Code\Python\PyOpenGL\ogl_01.py", line 7, in 
    from OpenGL.GL import *
  File "C:\Python26\lib\site-packages\pyopengl-3.0.1-py2.6-win32.egg\OpenGL\GL\__init__.py", line 2, in 
    from OpenGL.raw.GL import *
  File "C:\Python26\lib\site-packages\pyopengl-3.0.1-py2.6-win32.egg\OpenGL\raw\GL\__init__.py", line 6, in 
    from OpenGL.raw.GL.constants import *
  File "C:\Python26\lib\site-packages\pyopengl-3.0.1-py2.6-win32.egg\OpenGL\raw\GL\constants.py", line 7, in 
    from OpenGL import platform, arrays
  File "C:\Python26\lib\site-packages\pyopengl-3.0.1-py2.6-win32.egg\OpenGL\arrays\__init__.py", line 22, in 
    formathandler.FormatHandler.loadAll()
  File "C:\Python26\lib\site-packages\pyopengl-3.0.1-py2.6-win32.egg\OpenGL\arrays\formathandler.py", line 37, in loadAll
    cls.loadPlugin( entrypoint )
  File "C:\Python26\lib\site-packages\pyopengl-3.0.1-py2.6-win32.egg\OpenGL\arrays\formathandler.py", line 44, in loadPlugin
    plugin_class = entrypoint.load()
  File "C:\Python26\lib\site-packages\pyopengl-3.0.1-py2.6-win32.egg\OpenGL\plugins.py", line 14, in load
    return importByName( self.import_path )
  File "C:\Python26\lib\site-packages\pyopengl-3.0.1-py2.6-win32.egg\OpenGL\plugins.py", line 28, in importByName
    module = __import__( ".".join(moduleName), {}, {}, moduleName)
  File "C:\Python26\lib\site-packages\pyopengl-3.0.1-py2.6-win32.egg\OpenGL\arrays\numpymodule.py", line 25, in 
    from OpenGL_accelerate.numpy_formathandler import NumpyHandler
  File "numpy.pxd", line 30, in OpenGL_accelerate.numpy_formathandler (src\numpy_formathandler.c:3543)
ValueError: numpy.dtype does not appear to be the correct type object

Sorry for the length of the post, I just wanted to fully document the problem. The Py install is running on Win XP SP3, IDLE header:

Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32

Solution

  • I tried this and it worked in my case,

    1. went to http://pypi.python.org/pypi/PyOpenGL-accelerate and downloaded the zip source package.
    2. using 7zip I extracted the package to a folder named PyOpenGL-accelerate-3.0.1
    3. then using a command prompt, navigated to the folder I just created
    4. I typed C:\python26\python setup.py install to execute the package install

      Once this completed, I ran a basic OpenGL script in IDLE, Dr.Python, and PythonWin. All three IDEs were able to create the correct OpenGL window (a 400x400 window, black background, and a white wire-frame teapot.) without any errors. With this solution I was able to keep Numpy 1.6.