1.Python的安裝請參照
Anconda安裝_安裝anconda_lwb-nju的博客-CSDN博客anconda安裝教程_安裝ancondahttps://blog.csdn.net/lwbCUMT/article/details/125322193?spm=1001.2014.3001.5501
Anconda換源+虛擬環境創建及使用(界面操作)_anconda huanyuan_lwb-nju的博客-CSDN博客anconda簡單使用_anconda huanyuanhttps://blog.csdn.net/lwbCUMT/article/details/125322702?spm=1001.2014.3001.5501
2.OpenGL包的準備
使用pip和conda install安裝時會出現各種各樣的報錯
如:OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling
大佬都說是32位和64位不匹配,所以需要自己先下載好匹配的opengl包,這里我下載的是tar.gz格式的,whl格式的安裝后還是不能用,不知道為什么。下載地址:PyOpenGL -- The Python OpenGL Bindinghttps://pyopengl.sourceforge.net/
?
解壓后備用
3.安裝OpenGL包
cd xxdir #進入目標文件夾
python setup.py install #安裝
安裝過程中可能會報錯:error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools“:
根據提示下載一下C++組件后,再重新安裝。
4.測試
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *def drawFun():glClear(GL_COLOR_BUFFER_BIT)glutWireTeapot(0.5)glFlush()glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
glutInitWindowSize(400,400)
glutCreateWindow(b"hhh")
glutDisplayFunc(drawFun)
glutMainLoop()
技術支持可以mou魚 搜索GEEDOWNLOAD