对于Python项目,我需要PyOpenGL。我已经在PyCharm IDE中安装了它。
当我运行一个OpenGL程序来测试安装时,会出现以下错误消息:
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling.我在网站上搜索了一些可能的解决方案,并在StackOverflow找到了一些解决方案。我都试过了,但都没有用。
我在这里找到了那个博客:
https://block.arch.ethz.ch/blog/2016/10/pyopengl-glut-error/
我遵循了所有的指令,并在PyCharm IDE中得到了以下错误消息:
(virtual-environment) C:\Users\Rainer\PycharmProjects\MatchMover>pip install C:\Users\Rainer\Desktop\PyOpenGL-3.1.5-cp36-cp36m-win_amd64.whl
PyOpenGL-3.1.5-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.
You are using pip version 9.0.1, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.pip包已经手动更新为20.0.2版本,但与PyCharm IDE不同步。
我使用的是Windows 7计算机,Python3.6.3,,以及作为OpenGL的库,我使用freeglut。
下面是测试程序(摘自:https://codeloop.org/python-opengl-programming-creating-window/):
main.py
from OpenGL.GL import *
from OpenGL.GLUT import *
width, height = 500, 400
def draw():
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
glutSwapBuffers()
glutInit()
glutInitDisplayMode(GLUT_RGBA )
glutInitWindowSize(width, height)
glutInitWindowPosition(200, 200)
window = glutCreateWindow("Opengl Window In Python")
glutDisplayFunc(draw)
glutIdleFunc(draw)
glutMainLoop()发布于 2020-09-16 08:30:33
造成此错误的两个常见原因是…
这个包需要一个不同的系统类型(32位对64-bit).
但是正如您所说的,您有python3.6,所以我将把解决方案作为第一个选项。
修复要么下载另一个版本(32位,如果你下载64位,反之亦然)或改变车轮的文件名,如果你知道你需要的版本。
https://stackoverflow.com/questions/61017582
复制相似问题