google-code-export / django-photologue

Automatically exported from code.google.com/p/django-photologue
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Are the imports from PIL correct? #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
In photologue the imports from PIL are defined as:
import Image
import ImageFile
import ImageFilter

When I first used photologue I had to change this to:
from PIL import Image
from PIL import ImageFile
from PIL import ImageFilter

to get it to work on my mac. I thought at first it was a mac idiosyncrasy,
but since then I've noticed that 'from PIL import' is also needed for
Ubuntu, and is also the syntax used in Django-trunk. So I'm starting to
wonder if 'import Image' is the oddball case, not the other way round :-)

Comments anyone?

Richard

Original issue reported on code.google.com by richardb...@gmail.com on 1 Mar 2008 at 12:24

GoogleCodeExporter commented 9 years ago
Photologue uses the import paths specified in the PIL tutorial 
(http://www.pythonware.com/library/pil/handbook/introduction.htm). I have not 
installed PIL on my mac at 
home however so I can't test it myself right now. Did you install through 
Macports or build the dependancies 
yourself? If this is an issue a try/except block would be easy to implement:

try:
    import Image
except ImportError:
    try: 
        from PIL import Image
    except ImportError, err:
        raise ImportError("Photologue was unable to import the Python Imaging Library: %s" % err)

Original comment by justin.d...@gmail.com on 1 Mar 2008 at 3:45

GoogleCodeExporter commented 9 years ago
Hi,
I've installed PIL on my mac from fink binaries. Digging a bit deeper into this
subject, I found this http://code.djangoproject.com/ticket/6054 which suggests 
that
the PIL path can sometimes change according to the installation method. Which 
is weird.
Anyway, a try/except block as you suggested above works fine; I've attached a 
patch
with just that.

Original comment by richardb...@gmail.com on 1 Mar 2008 at 6:11

Attachments:

GoogleCodeExporter commented 9 years ago
Great. Thanks a lot for looking into this. Should save people some grief when 
trying to get this set up.

Original comment by justin.d...@gmail.com on 1 Mar 2008 at 6:44