Why you should never ever "import Image" with out a "from PIL"

108 views
Skip to first unread message

Ryexander

unread,
Jan 15, 2013, 2:24:47 PM1/15/13
to pyglet...@googlegroups.com
Because if you do it on a Mac and then at some other point in your code you 
form PIL import Image

or for that matter do the two calls in reverse

python will crash outright with the message
AccessInit: hash collision 3 for both 1 in 1

why? becasue mac is weird and python things the two Image modules are different thus tries to Load PIL twice.
why the crash doesn't happen on Lynix or windows I don't know but that's the way it is

So please, edit pyglet\image\codecs\pil.py and get rid of the stupid try statement
only use
form PIL import Image

the people who made PIL were stupid for allowing the other form anyway as it breaks namespaces.

Petr Viktorin

unread,
Jan 15, 2013, 3:12:13 PM1/15/13
to pyglet...@googlegroups.com
Here's another reason to do that:
There is a PIL fork called Pillow.[1] It's main claims to fame are
Python 3 compatibility and setuptools friendliness.
Form what I know at least Fedora is looking to replace PIL by Pillow
eventually.[2]

Pillow is a drop-in replacement for PIL, except -- you guessed it --
you have to write `form PIL import Image` instead of `import Image`.

[1] https://github.com/python-imaging/Pillow/
[2] https://fedoraproject.org/wiki/Features/Pillow
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/pyglet-users/-/ZMHC1EpQbk8J.
> To post to this group, send email to pyglet...@googlegroups.com.
> To unsubscribe from this group, send email to
> pyglet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyglet-users?hl=en.
Reply all
Reply to author
Forward
0 new messages