0

Retaining question for posterity; see workaround in edit

The Pyglet package comes installed at base and isn't removable. Using the current fully updated version 1.1.4 of Pyglet, I get repeatable errors related to importing the item pyglet.gl.gl_info; for instance, upon attempting to create a pyglet.window.Window(), upon trying to import pyglet.gl, or upon attempting to import pygarrayimage via from pygarrayimage.arrayimage import ArrayInterfaceImage.

In all such cases the relevant traceback ends with the uninformative message:

/Users/[username]/Library/Enthought/Canopy_64bit/System/lib/python2.7/site-packages/pyglet/image/__init__.py in <module>()
    142 
    143 from pyglet import gl
--> 144 from pyglet.gl import *
    145 from pyglet.gl import gl_info
    146 from pyglet import graphics

/Users/[username]/Library/Enthought/Canopy_64bit/System/lib/python2.7/site-packages/pyglet/gl/__init__.py in <module>()
    102 from pyglet.gl.glext_arb import *
    103 from pyglet.gl.glext_missing import *
--> 104 from pyglet.gl import gl_info
    105 
    106 import sys as _sys

ImportError: cannot import name gl_info

I am using OSX 10.6.8 on an Intel processor, with Canopy 64-bit, and these are 100% repeatable.

Given the traceback one might assume gl_info mistakenly isn't included, but this isn't the case. dir(pyglet.gl.gl_info) can successfully be run.

Edit: Solved this problem.

Pyglet 1.1.4 does not support 64-bit on OSX, so until Enthought packages a newer release of Pyglet in Canopy, here is a workaround for 64-bit OSX users.

  1. Acquire source for any release of Pyglet 1.2alpha1 or beyond.
  2. Extract source to your directory of choice.
  3. Append this directory to the beginning of your PYTHONPATH environment variable, in both ~/.bash_profile (for terminal shells) and /etc/launchd.conf (for GUI processes) with a line similar to: export PYTHONPATH=/Users/[username]/src/pyglet-1.2alpha1:$PYTHONPATH
  4. Run this bash command in an unrelated directory and confirm the path printed leads to your 1.2alpha1 source directory: $ python -c "import pyglet; print pyglet.__path__[0]"
Roman C
  • 49,761
  • 33
  • 66
  • 176

1 Answers1

0

If you don't wish to modify your bash_profile, you can simply do the following:

  1. Extract latest Pyglet source to your directory of choice and cd to that directory (it should contain a setup.py file).
  2. Use Canopy's Python to install Pyglet by doing the following (on Mac 64 bit): ~/Library/Enthought/Canopy_64bit/User/bin/python setup.py install

The location of Canopy's Python for different platforms is listed here:
https://support.enthought.com/entries/23646538-Make-Canopy-s-Python-be-your-default-Python-i-e-on-the-PATH-

pradyunsg
  • 18,287
  • 11
  • 43
  • 96
Prashant
  • 21
  • 2