Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51509 > unrolled thread

Pyglet on Python3.x, problems

Started byJohn Ladasky <john_ladasky@sbcglobal.net>
First post2013-07-29 15:04 -0700
Last post2013-07-30 02:38 +0100
Articles 6 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Pyglet on Python3.x, problems John Ladasky <john_ladasky@sbcglobal.net> - 2013-07-29 15:04 -0700
    Re: Pyglet on Python3.x, problems Joshua Landau <joshua@landau.ws> - 2013-07-30 00:14 +0100
      Re: Pyglet on Python3.x, problems John Ladasky <john_ladasky@sbcglobal.net> - 2013-07-29 17:34 -0700
    Re: Pyglet on Python3.x, problems Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-29 17:44 -0600
      Re: Pyglet on Python3.x, problems John Ladasky <john_ladasky@sbcglobal.net> - 2013-07-29 17:47 -0700
        Re: Pyglet on Python3.x, problems Chris Angelico <rosuav@gmail.com> - 2013-07-30 02:38 +0100

#51509 — Pyglet on Python3.x, problems

FromJohn Ladasky <john_ladasky@sbcglobal.net>
Date2013-07-29 15:04 -0700
SubjectPyglet on Python3.x, problems
Message-ID<cc9a7c29-5851-48ea-b2e1-22c5192071cf@googlegroups.com>
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.

https://groups.google.com/d/msg/comp.lang.python/ARtI0GC9RHc/_6URRrhz7nUJ

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 setup.py install", as I have done with many a package.  Then I tried running various programs in two directories (these programs are also on the pyglet.org web site).

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."

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:

=======================================================

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.

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

[toc] | [next] | [standalone]


#51519

FromJoshua Landau <joshua@landau.ws>
Date2013-07-30 00:14 +0100
Message-ID<mailman.5284.1375139697.3114.python-list@python.org>
In reply to#51509

[Multipart message — attachments visible in raw view] — view raw

On 29 July 2013 23:04, John Ladasky <john_ladasky@sbcglobal.net> wrote:

> 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.
>
> https://groups.google.com/d/msg/comp.lang.python/ARtI0GC9RHc/_6URRrhz7nUJ


I suggest you redirect to the archives from
http://mail.python.org/pipermail/python-list/.


> 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 setup.py install",
> as I have done with many a package.  Then I tried running various programs
> in two directories (these programs are also on the pyglet.org web site).
>
> 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.
>
...

> 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."
>
> Finally, I got errors when trying to run pyglet-1.2alpha1/tests/test.py.
>  At first, it looked like the fix would be easy:
>
...

> 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 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.
>
> So, there you have it, the two errors that I am encountering.  If anyone
> has any advice, I would appreciate it.  Thanks!
>

Seems relevant:
https://code.google.com/p/pyglet/issues/detail?id=615&colspec=ID%20Stars%20StatusType%20OpSys%20Modified%20Summary


If
https://code.google.com/p/pyglet/issues/detail?id=630&colspec=ID%20Stars%20StatusType%20OpSys%20Modified%20Summary
is
your problem then, for me:

>>> import pyglet
>>> pyglet.window
<pyglet._ModuleProxy object at 0x7ffab02cf690>
>>> pyglet.window.Window()
<pyglet.window.xlib.XlibWindow object at 0x7ffab02c7b50>

Window pops up.
It works! Sorry.

What happens when you help(pyglet) and help(pyglet.window) and
help(pyglet.window.Window)?

[toc] | [prev] | [next] | [standalone]


#51532

FromJohn Ladasky <john_ladasky@sbcglobal.net>
Date2013-07-29 17:34 -0700
Message-ID<1f999589-e446-483e-af77-f74c9ddba2a7@googlegroups.com>
In reply to#51519
Thanks for your reply, Joshua.

From the interpreter, I too can import pyglet, instantiate a pyglet.window.Window, and have it pop up (although, following your directions, now I can't CLOSE it because you didn't assign a name to it! :^]).  I can get all the help information as well.

It looks like Ian is on the right track (see below).  If I remove tests folder from within the pyglet-1.2alpha1 folder and then try to run test.py, it starts.

[toc] | [prev] | [next] | [standalone]


#51525

FromIan Kelly <ian.g.kelly@gmail.com>
Date2013-07-29 17:44 -0600
Message-ID<mailman.5290.1375141508.3114.python-list@python.org>
In reply to#51509
On Mon, Jul 29, 2013 at 4:04 PM, John Ladasky
<john_ladasky@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.

[toc] | [prev] | [next] | [standalone]


#51534

FromJohn Ladasky <john_ladasky@sbcglobal.net>
Date2013-07-29 17:47 -0700
Message-ID<7a49a3ab-070f-4c5f-baea-9faf4fc3a6f7@googlegroups.com>
In reply to#51525
Grrrr.  Ian, thank you, you gave me a clue.  I thought I was being careful about avoiding local imports.  I just removed the tests directory from inside the pyglet-1.2alpha1 directory and tried running it from its new location.  That got rid of the error message which was displaying uncorrected Python 2.x code, and now I am running tests.

I'm getting one problem.  After a few tests run, I can't close a window.  I am normally closing each interactive test with the ESC key.  But when that fails I try clicking with the mouse.  This also fails.  This broken behavior appears to be triggered when the window created by pyglet overlaps my terminal window and thereby steals the focus.  Any idea why that might be happening?

The GIF problem in animation.py persists in Python 3.3.  I tried it in Python 2 as you suggested, and it works there.  Odd.

[toc] | [prev] | [next] | [standalone]


#51535

FromChris Angelico <rosuav@gmail.com>
Date2013-07-30 02:38 +0100
Message-ID<mailman.5296.1375148296.3114.python-list@python.org>
In reply to#51534
On Tue, Jul 30, 2013 at 1:47 AM, John Ladasky
<john_ladasky@sbcglobal.net> wrote:
> I'm getting one problem.  After a few tests run, I can't close a window.  I am normally closing each interactive test with the ESC key.  But when that fails I try clicking with the mouse.  This also fails.  This broken behavior appears to be triggered when the window created by pyglet overlaps my terminal window and thereby steals the focus.  Any idea why that might be happening?


When you say "steals the focus", what exactly do you mean? Do the
windows normally get created without focus, but occasionally focus is
set to that window? Seems odd. If that's the case, is there any
difference if you click outside the window (eg on your terminal) and
then back in? Maybe there's something happening on gotfocus that
should happen on create.

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web