Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

python - Attempt to call an undefined function glutInit

I need a glut window in python. I have the following exception using Python 3.5 and PyOpenGL.GLUT

Traceback (most recent call last):
  File "D:...Test.py", line 47, in <module>

    if __name__ == '__main__': main()
  File "D:...Test.py", line 9, in main
    glutInit(sys.argv)
  File "C:...OpenGLGLUTspecial.py", line 333, in glutInit
    _base_glutInit( ctypes.byref(count), holder )
  File "C:...OpenGLplatformaseplatform.py", line 407, in __call__
    self.__name__, self.__name__,

OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit,
check for bool(glutInit) before calling

Platform: Windows

Why do i get this error?

Here is my code:

from OpenGL.GLUT import *
import sys

glutInit(sys.argv)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

Problems:

  • There was no problem with pip install or easy_install
  • The glut.dll and glut32.dll were missing. (They are not part of the PyPI package) you have to install them separately or download it like I did.

Unzipped the dll files from the glutdlls.zip and placed them next to my python file.

Note: You can add the dll files to your PATH variable. Not necessary to keep them next to the py file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share

755k questions

754k answers

5 comments

53.3k users

...