Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named OpenGL.GL

Tags:

python

opengl

I'm trying to run NeHe's tutorial here using Python 2.7.3, but It's throwing the error ImportError: No module named OpenGL.GL

So how do I fix that? This is the code:

from OpenGL.GL import *
like image 527
CyanPrime Avatar asked Jun 26 '12 20:06

CyanPrime


3 Answers

Do you have PyOpenGL installed correctly? If you are having n00bie issues getting new modules set up correctly, I recommend installing setuptools. Once you have setuptools installed, you will find a program in your python27/Scripts directory called "easy_install" that you can use to get packages installed correctly.

For instance on my windows setup, I use:

C:\Python27\scripts\easy_install pyopengl 

to set up PyOpenGL on my system, and then your example case works fine. I remember when I started using Python I had the same issues trying to get a working PyOpenGL set up correctly so I could run the NeHe code, and all of my issues went away when I learned about easy_install

On Linux:

sudo easy_install pyopengl 

As well as:

sudo apt-get install python python-numpy python-opengl python-qt4 python-qt4-gl 
like image 84
K. Brafford Avatar answered Sep 17 '22 21:09

K. Brafford


basically you need to install opengl but the library in python is called pyopengl not opengl you can use the pip install command inside anaconda prompt which can be done by the following command:

pip install pyopengl
like image 36
Karim Sherif Avatar answered Sep 18 '22 21:09

Karim Sherif


anaconda is a great python package manager,if you have anaconda,just:

conda install pyopengl
like image 44
dorbodwolf Avatar answered Sep 17 '22 21:09

dorbodwolf