Pyglet on Python3.x, problems

John Ladasky john_ladasky at
Tue Jul 30 00:04:18 CEST 2013

Hi folks,

For whatever reason, the pyglet package is getting a lot of attention on c.l.python these past few days.  I am guilty of generating some of that potentially off-topic conversation myself.  At the end of my last thread, I reported that I had found the pyglet-users newsgroup, and would direct my questions there.

Well, I joined pyglet-users.  I have waited for about 36 hours for the moderator to approve my first post asking for help.  Several other posts have appeared, but not mine.  I don't think that I was impolite.

Apologies to everyone, but I'm going to ask my questions here.  As you may recall, I'm teaching some adolescent computer programming students.  I need a Python 3-compatible GUI, preferably one oriented towards games.  I might have that GUI in hand, but I need to test it myself first.  I've been researching this issue for over a week.  I have a student tomorrow, so I'm facing a bit of a deadline.  (Yeah, I could teach him about B-trees instead, but... you know, kids.)

In my own defense, I'm not entirely certain that the problems I have encountered are specific to pyglet.  They might have to do with the limitations of the 2to3 program.

I'm starting with my own Ubuntu 13.04 system.  I downloaded pyglet-1.2alpha1, unzipped it and executed "sudo python3 install", as I have done with many a package.  Then I tried running various programs in two directories (these programs are also on the web site).

pyglet-1.2alpha1/examples/programming_guide/ runs fine.

pyglet-1.2alpha1/examples/programming_guide/ also runs fine.

pyglet-1.2alpha1/examples/programming_guide/ produces an error.  Here's the traceback.


Traceback (most recent call last):
  File "/usr/local/lib/python3.3/dist-packages/pyglet/", line 538, in animation
    identity = self._cached_animations[name]
  File "/usr/lib/python3.3/", line 69, in __getitem__
    o =[key]()
KeyError: 'dinosaur.gif'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 62, in <module>
    animation = pyglet.resource.animation('dinosaur.gif')
  File "/usr/local/lib/python3.3/dist-packages/pyglet/", line 540, in animation
    animation = pyglet.image.load_animation(name, self.file(name))
  File "/usr/local/lib/python3.3/dist-packages/pyglet/image/", line 2425, in load_animation
    raise first_exception  
  File "/usr/local/lib/python3.3/dist-packages/pyglet/image/", line 2417, in load_animation
    image = decoder.decode_animation(file, filename)
  File "/usr/local/lib/python3.3/dist-packages/pyglet/image/codecs/", line 121, in decode_animation
    gif_stream =
  File "/usr/local/lib/python3.3/dist-packages/pyglet/image/codecs/", line 85, in read
    raise ImageDecodeException('Not a GIF stream')
pyglet.image.codecs.ImageDecodeException: Not a GIF stream


>From earlier discussions, I know that distutils automatically executes 2to3 on the pyglet core module, when you invoke pyglet's file from Python 3.  The setup script does not appear to run 2to3 on the code outside of the package itself.  And while I doubted that the KeyError I saw above was a Python 2/3 compatibility issue, I tried running 2to3 on anyway.  2to3 seems to agree with me, reporting back "RefactoringTool: No files need to be modified."

Finally, I got errors when trying to run pyglet-1.2alpha1/tests/  At first, it looked like the fix would be easy:


File "tests/", line 274
  print '-' * 78
SyntaxError: invalid syntax


Clearly this was a problem for 2to3, so I ran it on  It corrected that one print statement, and nothing else.  Then I ran again.  This time I got a deeper problem:


Traceback (most recent call last):
  File "", line 215, in <module>
    import tests.regression
  File "../tests/regression/", line 11, in <module>
    from pyglet.image import get_buffer_manager
  File "../pyglet/", line 276
    print '[%d] %s%s %s' % (thread, indent, name, location)
SyntaxError: invalid syntax


This error suggests that, during the build and install process, 2to3 left some code uncorrected in pyglet/  This has me worried.  Could there be other code that 2to3 failed to correct?  I don't want to offer my students a tool, only to have it crash on them.

So, there you have it, the two errors that I am encountering.  If anyone has any advice, I would appreciate it.  Thanks!

More information about the Python-list mailing list