python - 在Python 2.6.6中使用pyopengl遇到麻烦

标签 python error-handling python-2.x pyopengl

我想做的是编写一个基本的OpenGL 2.0窗口的代码,当我从文件中运行代码时,它在前几次运行中都起作用,然后转储错误。如果我从IDLE GUI运行相同的代码,则每次都会得到一个窗口。以下是已添加的Python 2.6.6软件包,代码和错误的列表。我在使用任何有冲突的软件包吗?我是否缺少包裹?我的导入工作在IDLE GUI中。任何帮助将是巨大的!

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

最佳答案

OpenGL的numpy Cython扩展可能是用numpy 1.3.x构建的。因此,要么使用新的numpy版本重新编译OpenGL(尤其是Cython扩展名),要么将numpy降级至1.3.x。 (如果这也无济于事,请尝试同时降级到1.4.x和1.5.x-因为我不完全知道哪个版本中发生了什么更改)。

关于python - 在Python 2.6.6中使用pyopengl遇到麻烦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7006040/

相关文章:

python - 使用 `python setup.py develop` 安装更多文件

Python __hash__ : identity vs. 等价

python - 使用 BeautifulSoup 解析 HTML 标签

api - 使用远程API时处理错误

python - 如何防止我的 Python 应用程序在到达代码末尾时自动关闭?

python - 在 Python 中测试实际相等性

python - 为什么 `obj.method is obj._class__method` 是假的

python - SQLAlchemy 和 Falcon - session 初始化

c - 用于调试我的操作系统的调试器

python - 无法使用BeautifulSoup获取div文本