I am trying to run this code:
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
But I get this error:
Traceback (most recent call last):
File "/Users/Abood/Documents/lol.py", line 3, in <module>
from OpenGL.GL import *
ModuleNotFoundError: No module named 'OpenGL.GL'
I tried removing the .GL part and this came up:
Traceback (most recent call last): File "/Users/Abood/Documents/lol.py", line 4, in <module> from OpenGL.GLU import * ModuleNotFoundError: No module named 'OpenGL.GLU'
You have to install both the pygame and OpenGL packages. The easiest way is using pip
:
pip install pygame
pip install PyOpenGL
This worked for me. After installing the packages and running your code, I got:
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
There are also different ways to install the OpenGL module. See the installation instructions on the PyOpenGL website .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.