Closed GoogleCodeExporter closed 8 years ago
Thanks for your report!
Original comment by useboxnet
on 26 Feb 2014 at 7:29
Something is not OK in your installation, running 3.3.2 here (Linux) with
Pillow 2.0.0 works as expected (see attachment).
Also I've noticed in your traceback that your code is using pypng instead of
PIL (Pyllow) and that happens only if you're using that encoder explicitly or
PIL is not found.
I've forced the pypng encoder with:
def take_snapshot(dt):
from pyglet.image.codecs.png import PNGImageEncoder
pyglet.image.get_buffer_manager().get_color_buffer().save('screenshot.png', encoder=PNGImageEncoder())
But it works, I could get the screenshot, so it might be related to python
3.3.1. I'll investigate further to see if I can reproduce it but I'd appreciate
if you can confirm that using PIL works for you too. Thanks!
Original comment by useboxnet
on 6 Mar 2014 at 9:14
Attachments:
I inspected the file site-packages/pyglet/image/codecs/pil.py in the pyglet
installation under py3.
Found this suspicious snippet near the start of file:
try:
import Image
except ImportError:
from .PIL import Image
That .PIL looks wrong.
Removing the '.' fixes the problem for me.
As that '.' does not show in the pyglet checkout, it must have been introduced
by the 2to3 performed in the py -3.3 setup.py install
As to why you can't reproduce, it may be a difference in pillow version: mine
is the latest, the 2.3.0, yours is older, a 2.0.0.
And I remember for some previous version a warning in the pypi page along the
lines:
'import Image' is not supported from version ???, please use
'from PIL import Image'
(I checked pypi now and the current pillow page don't shows this warning)
So, if your version still supports 'import Image', I can see why you don't hit
the faulty line.
Another possibility is that the 2to3 in my python 3.3.1 win32bits added the
'.', and your version not.
Can you look your py3 pyglet installation to see if you also have the offending
'.' ?
And maybe put a print to clarify if the flow goes trough the except branch ?
Original comment by ccanepacc@gmail.com
on 7 Mar 2014 at 7:26
That's interesting. Thanks for the follow up, I'll try latest version of Pillow
and I'll try to investigate why is that dot added by 2to3.
Good catch!
Original comment by useboxnet
on 7 Mar 2014 at 8:08
The '.' is an artifact produced by 2to3 in windows.
I will fill a bug in python bugtracker, it is still present in cpython default
branch.
The core of the 2to3 issue is the heuristic "if file A has a non doted import,
and there exists a file B in the same directory which matchs the import target
(plus .py, .pyc,...) then add a '.' in the import "
The implementation checks if os.path.exists(name) , but Windows filenames are
case-insensitive, and pyglet has a module pil , lowercase. Hence the problem.
Later I will follow up with the python issue #
Original comment by ccanepacc@gmail.com
on 7 Mar 2014 at 5:32
I was suspecting something like that. There's a pil.py in that directory, but
it is lower case!
Well, Windows... upper/lower case, who cares! ;)
Original comment by useboxnet
on 7 Mar 2014 at 5:34
Original comment by useboxnet
on 7 Mar 2014 at 5:35
2to3 bug reported at python bugtraker, under
http://bugs.python.org/issue20867
Original comment by ccanepacc@gmail.com
on 7 Mar 2014 at 9:18
Claudio, I've thinking about this issue... can you try the following patch to
see if it works as a workaround?
Thanks!
Original comment by useboxnet
on 29 Mar 2014 at 11:56
Attachments:
I found something simpler: add a
from __future__ import absolute_import
to pil.py , before any other import
Applying this change to a pyglet checkout and then installing to 3 by
cd working_copy
py -3.3 setup.py install
1. prevents the unwanted '.'
2. the imports sections in the installed pil.py looks same as ( installed
unpatched pyglet + manually removing the '.' )
3. The failing script runs ok
I think this is a clearer fix to the 'failure to use pillow'.
From your comment 2 I suspected the pil fallback (pypng) was also acting up,
and doing some testing confirms that. I will do a new issue for that.
Original comment by ccanepacc@gmail.com
on 29 Mar 2014 at 1:48
Excellent, I like your idea better. I'm going to test it and commit it if I
can't find anything weird.
So the issue was pypng being used instead of PIL because of the import but in
2to3. It would be great if you could open a new issue so we can close this one.
Thanks for the follow up!
Original comment by useboxnet
on 29 Mar 2014 at 1:52
done,
issue #717: pypng tracebacks when trying to save (bytes vs str problem)
Original comment by ccanepacc@gmail.com
on 29 Mar 2014 at 2:03
This issue was closed by revision 489162ee33f1.
Original comment by useboxnet
on 29 Mar 2014 at 2:05
Original issue reported on code.google.com by
ccanepacc@gmail.com
on 25 Feb 2014 at 8:12Attachments: