1
直接在终端使用命令:
pip install pyopengl pyopengl_accelarate
然后执行一下程序测试:
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
def Draw():
glClear(GL_COLOR_BUFFER_BIT)
glRotatef(0.5, 0, 1, 0)
glutWireTeapot(0.5)
glFlush()
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
glutInitWindowSize(400, 400)
glutCreateWindow("test")
glutDisplayFunc(Draw)
glutIdleFunc(Draw)
glutMainLoop()
出错,error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
在不知道下载的库是什么版本时出错在所难免
2
去官网下载相应的库,由于我的python版本为3.6的,因此我下载了
PyOpenGL‑3.1.2‑cp36‑cp36m‑win_amd64.whl(放到某一能记得住的目录,cp36说明是python3.6版本的)
下载网站为:https://www.lfd.uci.edu/~gohlke/pythonlibs
再使用pip install .whl,终于成功解决了这个问题
3
于是我上官网再下载了PyOpenGL_accelerate‑3.1.2‑cp36‑cp36m‑win_amd64.whl,发现又有新的问题
AttributeError: module 'OpenGL_accelerate' has no attribute '__version_tuple__'
之后好像重新重启了IDE就可以了
运行结果如下: