diff --git a/pyopencl/tools.py b/pyopencl/tools.py
index ea0d66dbdfda9cfd7858d085a5291a02e403afe6..ceaa2350c8f7626359b0087364dd68ac44561c09 100644
--- a/pyopencl/tools.py
+++ b/pyopencl/tools.py
@@ -419,18 +419,20 @@ def get_arg_offset_adjuster_code(arg_types):
 def get_gl_sharing_context_properties():
     ctx_props = cl.context_properties
 
-    from OpenGL import platform as gl_platform, GLX, WGL
+    from OpenGL import platform as gl_platform
 
     props = []
 
     import sys
     if sys.platform in ["linux", "linux2"]:
+        from OpenGL import GLX
         props.append(
             (ctx_props.GL_CONTEXT_KHR, gl_platform.GetCurrentContext()))
         props.append(
                 (ctx_props.GLX_DISPLAY_KHR,
                     GLX.glXGetCurrentDisplay()))
     elif sys.platform == "win32":
+        from OpenGL import WGL
         props.append(
             (ctx_props.GL_CONTEXT_KHR, gl_platform.GetCurrentContext()))
         props.append(