Installing (and Building) PyOpenGL
This document describes the process of
installing PyOpenGL 2.0.1.
Most users should be able to download pre-compiled binary
for their system (eventually). Those wishing to build from source will
need the detailed build instructions below.
PyOpenGL has a number of dependencies which need to be installed
before installing PyOpenGL. This list should point you to
everything you need to get ready for running PyOpenGL:
- Python 2.2.x+
- Python 2.3+ is recommended.
- Python 2.2.3+ is required
by OpenGLContext (but not by PyOpenGL)
- Tcl/Tk appropriate for your Python version
- OpenGL 1.1 and GLU (available pre-installed on most modern
- If your machine is a very old Win95 machine that has never had
an OpenGL game, package, or graphics-card installed it is possible that
you don't have OpenGL installed. You can get it from
Microsoft in this (rare) case. Because of MSDN's rather
capricious content-management system, that link may fail at some point.
Search for OpenGL95.exe on Microsoft's site to find it if this
- Available as an rpm/deb/ebuild for most modern Linux machines
- Note that you will often need the "dev" RPM as well as the
- Available as a Win32 binary package
Imaging Library (PIL) any recent version
- Not technically required for PyOpenGL, but you'll almost
certainly need it
- Required for OpenGLContext (for all but the most simplistic of
Python (Numpy) v. 23 (for PyOpenGL 2.0.1.08)
- You may use another version of Numeric Python iff you are building from source.
Be very sure that the Numeric Python libs and headers available
during build are for the installed version and that you do not use a
PyOpenGL compiled for one with the other.
If you use a version other than that used to
PyOpenGL, you will get bugs
failures in your code! In particular, PyOpenGL 2.0.0.x releases
were all compiled with Numeric Python 19 through 21 (all of which were
compatible), as such, those releases will
not work with Numeric Python v22, and the Numeric
Python versions used for them will not work with PyOpenGL
The PyOpenGL 2.0.1.07 binary was (mistakenly) compiled with NumArray
installed, so depends on it as well.
Upshot is that you need to upgrade Numeric
Python and PyOpenGL at the same time
if you are using the binary builds.
OpenGLContext has a few extra dependencies:
- Provides the event-routing and field-watching infrastructure
for the scenegraph
2.1 (or 2.0.x)
- Provide the VRML97 parser, strongly recommended, but
- Provide access to TrueType fonts stored in the file system,
used by the "toolsfont" and "pygamefont" modules in the scenegraph/text
package. Without these modules, you will not have access to
extruded fonts (toolsfont) or antialiased bitmap fonts (pygamefont)
- Additional contexts/windowing environments, only GLUT contexts
are available otherwise.
- PyGame also provides antialiased bitmap fonts, while wxPython
can provide aliased bitmap fonts if necessary
- win32ui and win32con provide support for WGL-based polygonal
text, only available for Win32 systems of course. The WGL
polygonal text is not used by the scenegraph engine, so it is not
required for anything save playing with the WGL polygonal text
You can download the installers for PyOpenGL and OpenGLContext from
the project's download
page. These installers are standard binary installers.
If binary installers are not available, you will have to build
PyOpenGL before you can install it. See the next section for
If a binary installer for OpenGLContext is not available, you can
use the source archive instead. Simply unzip the archive to a
temporary directory. Switch to the top-level "OpenGLContext-YYY"
directory and execute:
python setup.py install
or, for Linux systems where Python 2.2.x is available as python2:
python2 setup.py install
which will install the package.
This section describes the process of building
PyOpenGL from source, either a source distribution, or CVS. If
are just interested in running PyOpenGL, and there are binary
available for your platform, see the previous section.
Extra setup steps before building from source:
- Make the GL, GLU and GLUT headers available to distutils
- On Win32 for MSVC++ (which doesn't really have global
include/lib directories), you can create directories at the same level
as the source root named include and lib (i.e. ..\include and ..\lib
searched for the libraries)
- Files are: GL.h, GLAUX.h, GLU.h, glut.h, glsmap.h
- If you're on Win32 and don't have a copy of the headers/libs,
the SGI Win32 OpenGL distribution has base-library headers which can be
used, as does the OpenGL95.exe archive described above
- To build the Togl component for Tkinter from source you will need
to install a Tcl/Tk distribution, we recommend using the distribution
from the Tcl/Tk
project at SourceForge
- Note that most Linux/Unix machines will probably already have
these headers properly installed.
- In particular, the header and library (.h and .lib
respectively) files need to be available to the compiler.
- If your
platform does not have standard include or library directories, you may
want to copy them to the Python/include and Python/libs directories
- Alternately, when building PyOpenGL, specify:
--tk-source=/path/to/source --tcl-source=/path/to/sourceto add the library and header directories to the path (new
in PyOpenGL 2.1)
- See platform specific build notes, particularly for Win32
- If building from CVS (not a source archive, which includes the
wrappers already), install SWIG
1.3.13 (no other version)
and put the directory with swig.exe on your path where distutils can
Note that you can only build on Win32 systems for
use with PythonLabs Python by using the Microsoft VC++ compiler.
Mingw32 chokes on trying to link the dlls.
You can find platform-specific build notes at the end of this
Getting the PyOpenGL source from CVS instead of a source
cvs -d:pserver:firstname.lastname@example.org:/cvsroot/pyopengl login
Hit <enter> when prompted to give the default null password.
Then checkout the PyOpenGL2 project using the following:
cvs -z3 -d:pserver:email@example.com:/cvsroot/pyopengl co PyOpenGL2
To check out the OpenGLContext module, use the same command, but
checkout the modules "OpenGLContext" and "vrml".
Build Commands and Rebuilding
Once the system setup is done, and you've got the PyOpenGL source in
a directory on disk. Switch to that directory (PyOpenGL2 if using
CVS, PyOpenGL-Y.Y.Y if using a source archive) and run the standard
setup.py build --force install
which will force a re-wrap, rebuild and install from your local
setup.py build_ext --force install
will skip the wrapping stage if possible.
Note that currently we don't include the SWIG
wrappers in the CVS repository, so unless you got them from somewhere
else, the non-wrapping command won't work until the first command has
been run successfully. The wrappers are very large and change
constantly, and unless there is real need for them, we'd rather not
clutter up the CVS archive with them.
Note that you can force a single module to rebuild
by "touch"-ing the .i file (in PyOpenGL2/interface) which defines the
wrapper for that module. This is useful during development as it
allows the first build-line above to go about wrapping and building the
single extension with only minimal processing of the rest of the
Building the documentation-set from source uses Java-based DocBook
processing scripts, so it can take quite a bit of work to set up
properly. Most developers will never need to do this, but future
administrators (such as myself) will likely want some instructions.
Here's the steps.
- Install Java
- Install the Saxon
Java XSLT processor
- Add Saxon install root directory (where saxon.jar is) to the
system environment as SAXON_HOME
- Install the DocBook-XSL
as PyOpenGL2\doc\docbook-xsl within the source-tree (this will require
renaming the directory from something like 'docbook-xsl-1.59.1' to
- Add PyOpenGL2\doc\docbook-xsl to the shell environment as
DOCBOOK_XSL_HOME (note that you still must use the doc\docbook-xsl
directory even with the variable set)
- Install Sun's Resolver
- Add the resolver root directory (where the file resolver.jar
is) to the system environment as RESOLVER_HOME
- Download the Oasis
XML Docbook catalog and DTD (optional, but speeds up processing
- Expand into the PyOpenGL2\doc\docbook directory
- Create a file named CatalogManager.properties in
PyOpenGL2\doc\docbook with these contents (where catalog.xml is the
filename of the Oasis XML catalog). Note that the
PyOpenGL2\doc\docbook directory is added to the classpath to make this
file available to the resolver. Note also that the
relative-catalogs value seems to be somewhat fickle, you may want to
try "false" if saxon is complaining about missing entity files:
- Install the MathML DTD in PyOpenGL2\doc\docbook\mathml\
- Add these declarations to the PyOpenGL2\doc\docbook\catalog.xml
file (the last lets the 4.1.2 documents use the 4.2 DTD), the others
make the various parts of the mathml dtd available:
<public publicId="-//W3C//DTD MathML 2.0//EN"
<public publicId="-//W3C//ENTITIES MathML 2.0 Qualified Names 1.0//EN"
<public publicId="-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
<public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
- Install David Carlisle's MathML XSL stylesheets into
- (For HTML Help) Add the directory with the hhc.exe file from the
html help workshop to your path.
Note that the HTML-help feature is not likely to
stylesheets above. Expect the results to be either unreadable or
simply fail to be generated.
- Run setup.py build_doc --formats=html,htmlhelp (warning, this
will take a very long time to complete (figure an
hour or so at least))
Platform-specific Build Notes
Note: these notes are not necessarily still relevant to the current
builds of PyOpenGL, if you find an out-of-date note, please inform the PyOpenGL-devel
list. If you have built PyOpenGL on a platform not described here,
please let us know, particularly if there are any nonstandard
required. The eventual goal is to have the entire build process
most platforms consist of "python setup.py install" once the required
dependencies are installed.
RedHat Linux 8.0
Delete any old version of
- not available by default, needed to install it.
- not available by default, is required by tkinter
- "setup.py build install"
- Note: if you want to build and install PyOpenGL from RPM,
you'll need to install Numeric from RPM as well, which is a fairly
trivial process, simply do a
setup.py bdist_rpm and then
install the RPM.
- Just a standard install, not required for packaged
distributions, but required for building from CVS.
- (not actually required for PyOpenGL, may require some
Mandrake Linux (for PyOpenGL 2.0.0)
Some Mandrake distrubutions don't use /usr/X11 as the X11
directory. Instead they use
/usr/X11R6 and don't
/usr/X11 as a link to
- One solution is link
- Another solution is to add the X11R6 directories to the
configuration file: config/linux.cfg.
PyOpenGL 2.0.1.07+ includes the directories in the linux.cfg file
Win2K (MS (Free) Toolkit Compiler)
PyOpenGL can be built for Python 2.4a1 with the MS Toolkit
Compiler. You will need to follow the setup
instructions for building Python extensions with the compiler, then
continue with the setup instructions below for MSVC++6.0).
- Win2K, MS Toolkit, Python 2.4.0a1, Numeric 23
Win2K (MSVC++ 6)
These are the instructions for "packagers" building PyOpenGL from
source on Win32 systems with Visual C++ from Microsoft:
- VC++ (minimum of VC++ runtime libraries, VC++ build tools, and
the "data access" set, register environmental variables)
- Note: environmental variables must be set to operate
properly. You should be able to type 'cl' on the command line to
invoke the VC++ compiler.
- Put OpenGL, GLU and GLUT headers and libs somewhere they can be
- Add the directory to the system paths (environment 'INCLUDE'
and 'LIB' respectively)
- In the ../include and ../lib directories respectively
- In the Python/include and Python/libs directories respectively
Note: the OpenGL/GLU/GLUT headers should be in the
subdirectory <path>/GL/*.h, while the libraries should be
on the LIB path <path>/*.lib
- Install Numeric Python 23 or 21 into your Python installation
- Install Tcl/Tk to acquire the Tcl/Tk header files required for
- See note above on OpenGL headers for potential locations for
the headers and libs
python.exe setup.py install
- Win2K, VC6 SP5, Python 2.3.4, Numeric 23
- Win2K, VC6 SP5, Python 2.2.2, Numeric 23 & 21
- Win98, VC6 SP5, Python 2.2.1
Note that this setup has been built, but not
tested extensively. It is not recommended for anyone who isn't
ready to fix lots of bugs.
To build PyOpenGL on Win32 linked against the Mesa DLLs:
- build the Mesa package as instructed in the Mesa documentation
- copy the .lib files to a location on your LIB path
- copy the .dll files to your system directory.
Change the win32.cfg file to explicitly specify the Mesa versions of
; a os.pathsep separated list of the libs needed when linking GLU
; the GL libraries are included automatically
; a os.pathsep separated list of the libs needed when linking GLUT
; the GL and GLU libraries are included automatically
and do a setup.py build_ext --force install.
Mesa GLU Headers
Note: most (all) recent Linux distributions will
probably already have upgraded Mesa beyond this level, so you quite
likely will not need to follow the above instructions.
Mesa users should beware of Mesa versions 3.1 and 3.2 which have
GLU headers which declare themselves as GLU 1.2 but are really GLU 1.1
headers. This will make compilation of the GLU module fail. There are
four possible workarounds for this:
- First extract PyOpenGL-220.127.116.11.tar.gz then
mesa-setup-patch.tar.gz from the same folder. This will add a
to the setup script.
- Comment out the line "#define GLU_VERSION_1_2 1" in the GLU
- Upgrade to the SGI GLU library which supports GLU 1.3 and is
available via RPM at the Mesa homepage.
- Upgrade Mesa, also available at the Mesa homepage.