Pyglet on Python3.x, problems

Ian Kelly ian.g.kelly at gmail.com
Mon Jul 29 19:44:18 EDT 2013


On Mon, Jul 29, 2013 at 4:04 PM, John Ladasky
<john_ladasky at sbcglobal.net> wrote:
> pyglet-1.2alpha1/examples/programming_guide/hello_world.py runs fine.
>
> pyglet-1.2alpha1/examples/programming_guide/image_viewer.py also runs fine.
>
> pyglet-1.2alpha1/examples/programming_guide/animation.py produces an error.  Here's the traceback.
>
> =======================================================
>
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.3/dist-packages/pyglet/resource.py", line 538, in animation
>     identity = self._cached_animations[name]
>   File "/usr/lib/python3.3/weakref.py", line 69, in __getitem__
>     o = self.data[key]()
> KeyError: 'dinosaur.gif'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "animation.py", line 62, in <module>
>     animation = pyglet.resource.animation('dinosaur.gif')
>   File "/usr/local/lib/python3.3/dist-packages/pyglet/resource.py", line 540, in animation
>     animation = pyglet.image.load_animation(name, self.file(name))
>   File "/usr/local/lib/python3.3/dist-packages/pyglet/image/__init__.py", line 2425, in load_animation
>     raise first_exception
>   File "/usr/local/lib/python3.3/dist-packages/pyglet/image/__init__.py", line 2417, in load_animation
>     image = decoder.decode_animation(file, filename)
>   File "/usr/local/lib/python3.3/dist-packages/pyglet/image/codecs/gdkpixbuf2.py", line 121, in decode_animation
>     gif_stream = gif.read(file)
>   File "/usr/local/lib/python3.3/dist-packages/pyglet/image/codecs/gif.py", 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 setup.py 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 animation.py anyway.  2to3 seems to agree with me, reporting back "RefactoringTool: No files need to be modified."

>From the error message my first guess would be that the example is
broken because the 'dinosaur.gif' file is either missing or corrupt.
Have you tried running the same example in Python 2?

> Finally, I got errors when trying to run pyglet-1.2alpha1/tests/test.py.  At first, it looked like the fix would be easy:
>
> =======================================================
>
> File "tests/test.py", line 274
>   print '-' * 78
>           ^
> SyntaxError: invalid syntax
>
> =======================================================
>
> Clearly this was a problem for 2to3, so I ran it on test.py.  It corrected that one print statement, and nothing else.  Then I ran test.py again.  This time I got a deeper problem:

This is in the directory that you extracted the files into, not the
installation directory, correct?  If so, I'm not surprised that the
files in that location haven't been ported by the installer.  The
question then would be "what's the proper way to run the tests under
Python 3", which I don't know the answer to.

> =======================================================
>
> Traceback (most recent call last):
>   File "test.py", line 215, in <module>
>     import tests.regression
>   File "../tests/regression/__init__.py", line 11, in <module>
>     from pyglet.image import get_buffer_manager
>   File "../pyglet/__init__.py", 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/__init__.py.  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.

The traceback is using ../pyglet, not your system installation of
pyglet, so as with the above it looks like this hasn't been ported
because it's the raw copy in the installation directory.  If that code
had not been ported in the system installation then you would not even
be able to "import pyglet" without getting an error, which you clearly
are able to do since you said the first two examples worked for you.



More information about the Python-list mailing list