import ICCProfile Error

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

import ICCProfile Error

Bharathwaaj S-2
Hi,

I keep getting error in import ICCProfile in PNGImagePlugin.py _save.

What am I missing? Which package contains ICCProfile?

I've been searching but couldn't get a clue on why it is failing.

The support was added as mentioned here:
http://mail.python.org/pipermail/image-sig/2009-March/005460.html

Kind regards,
Bharath



_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Fredrik Lundh
On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan
<[hidden email]> wrote:
> I keep getting error in import ICCProfile in PNGImagePlugin.py _save.
>
> What am I missing? Which package contains ICCProfile?

Not sure why that code was left in there, but iirc it's an extension hook.

> I've been searching but couldn't get a clue on why it is failing.

Me neither, given that the import is protected by a try/except.

   try:
       import ICCProfile
   except ImportError:
       ...

What exactly are you doing when you get this import error, and what
does the full traceback look like?

</F>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Bharathwaaj S-2
I'm trying to get the images-demo working for google appengine.

http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo

The full traceback can be found here:

http://pastebin.com/cBn6cA0V

Kind regards,
Bharath

On 13 November 2010 02:04, Fredrik Lundh <[hidden email]> wrote:
On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan
<[hidden email]> wrote:
> I keep getting error in import ICCProfile in PNGImagePlugin.py _save.
>
> What am I missing? Which package contains ICCProfile?

Not sure why that code was left in there, but iirc it's an extension hook.

> I've been searching but couldn't get a clue on why it is failing.

Me neither, given that the import is protected by a try/except.

  try:
      import ICCProfile
  except ImportError:
      ...

What exactly are you doing when you get this import error, and what
does the full traceback look like?

</F>


_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Fredrik Lundh
On Fri, Nov 12, 2010 at 10:33 PM, Bharathwaaj Srinivasan
<[hidden email]> wrote:
> I'm trying to get the images-demo working for google appengine.
>
> http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo
>
> The full traceback can be found here:
>
> http://pastebin.com/cBn6cA0V

Hmm. First time I've ever seen that error in any context.  Looks like
GAE's import mechanisms cause some trouble for relative imports that
won't happen if you run things stand-alone.  And it looks like PIL's
far from the only library suffering from this:

http://www.google.com/search?q=%22SystemError:+Parent+module+*+not+loaded%22

even if most PIL reports I found seem to be for GAE.  My guess is that
it's some misfeature in the changes to relative import that was
introduced in 2.6 (iirc), but since it doesn't happen when you run PIL
in a normal configuration, I'm not sure how to debug it.  If someone
can come up with a simple test case that triggers this, let me know.

I guess this also means that adding an ICCProfile module to the path
won't help you; if you cannot figure out something better, you might
have to comment out the problematic code (or you could try replacing
the relative import with a "from PIL import" and see if that helps).

</F>

> On 13 November 2010 02:04, Fredrik Lundh <[hidden email]> wrote:
>>
>> On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan
>> <[hidden email]> wrote:
>> > I keep getting error in import ICCProfile in PNGImagePlugin.py _save.
>> >
>> > What am I missing? Which package contains ICCProfile?
>>
>> Not sure why that code was left in there, but iirc it's an extension hook.
>>
>> > I've been searching but couldn't get a clue on why it is failing.
>>
>> Me neither, given that the import is protected by a try/except.
>>
>>   try:
>>       import ICCProfile
>>   except ImportError:
>>       ...
>>
>> What exactly are you doing when you get this import error, and what
>> does the full traceback look like?
>>
>> </F>
>
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Fredrik Lundh
By the way, I'm pretty sure that this only happens for some PNG
images, and once you upload your application, PNG reading is done by
GAE:s image library, not PIL, so the application you're building
should be fine.

</F>

On Sat, Nov 13, 2010 at 2:40 PM, Fredrik Lundh <[hidden email]> wrote:

> On Fri, Nov 12, 2010 at 10:33 PM, Bharathwaaj Srinivasan
> <[hidden email]> wrote:
>> I'm trying to get the images-demo working for google appengine.
>>
>> http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo
>>
>> The full traceback can be found here:
>>
>> http://pastebin.com/cBn6cA0V
>
> Hmm. First time I've ever seen that error in any context.  Looks like
> GAE's import mechanisms cause some trouble for relative imports that
> won't happen if you run things stand-alone.  And it looks like PIL's
> far from the only library suffering from this:
>
> http://www.google.com/search?q=%22SystemError:+Parent+module+*+not+loaded%22
>
> even if most PIL reports I found seem to be for GAE.  My guess is that
> it's some misfeature in the changes to relative import that was
> introduced in 2.6 (iirc), but since it doesn't happen when you run PIL
> in a normal configuration, I'm not sure how to debug it.  If someone
> can come up with a simple test case that triggers this, let me know.
>
> I guess this also means that adding an ICCProfile module to the path
> won't help you; if you cannot figure out something better, you might
> have to comment out the problematic code (or you could try replacing
> the relative import with a "from PIL import" and see if that helps).
>
> </F>
>
>> On 13 November 2010 02:04, Fredrik Lundh <[hidden email]> wrote:
>>>
>>> On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan
>>> <[hidden email]> wrote:
>>> > I keep getting error in import ICCProfile in PNGImagePlugin.py _save.
>>> >
>>> > What am I missing? Which package contains ICCProfile?
>>>
>>> Not sure why that code was left in there, but iirc it's an extension hook.
>>>
>>> > I've been searching but couldn't get a clue on why it is failing.
>>>
>>> Me neither, given that the import is protected by a try/except.
>>>
>>>   try:
>>>       import ICCProfile
>>>   except ImportError:
>>>       ...
>>>
>>> What exactly are you doing when you get this import error, and what
>>> does the full traceback look like?
>>>
>>> </F>
>>
>>
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Fredrik Lundh
So after digging a bit further, the suspect is the auto-reload
mechanisms in GAE's development appserver -- the appserver attempts to
clear out all imported modules in sys.modules when it detects changes
to your application code, and that process apparently leaves the PIL
modules in a half-baked state (i.e. "PIL" has been removed, but code
for "PIL.PngImagePlugin" is still around).

You're not importing PIL code directly, are you?

</F>

On Sat, Nov 13, 2010 at 3:17 PM, Fredrik Lundh <[hidden email]> wrote:

> By the way, I'm pretty sure that this only happens for some PNG
> images, and once you upload your application, PNG reading is done by
> GAE:s image library, not PIL, so the application you're building
> should be fine.
>
> </F>
>
> On Sat, Nov 13, 2010 at 2:40 PM, Fredrik Lundh <[hidden email]> wrote:
>> On Fri, Nov 12, 2010 at 10:33 PM, Bharathwaaj Srinivasan
>> <[hidden email]> wrote:
>>> I'm trying to get the images-demo working for google appengine.
>>>
>>> http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo
>>>
>>> The full traceback can be found here:
>>>
>>> http://pastebin.com/cBn6cA0V
>>
>> Hmm. First time I've ever seen that error in any context.  Looks like
>> GAE's import mechanisms cause some trouble for relative imports that
>> won't happen if you run things stand-alone.  And it looks like PIL's
>> far from the only library suffering from this:
>>
>> http://www.google.com/search?q=%22SystemError:+Parent+module+*+not+loaded%22
>>
>> even if most PIL reports I found seem to be for GAE.  My guess is that
>> it's some misfeature in the changes to relative import that was
>> introduced in 2.6 (iirc), but since it doesn't happen when you run PIL
>> in a normal configuration, I'm not sure how to debug it.  If someone
>> can come up with a simple test case that triggers this, let me know.
>>
>> I guess this also means that adding an ICCProfile module to the path
>> won't help you; if you cannot figure out something better, you might
>> have to comment out the problematic code (or you could try replacing
>> the relative import with a "from PIL import" and see if that helps).
>>
>> </F>
>>
>>> On 13 November 2010 02:04, Fredrik Lundh <[hidden email]> wrote:
>>>>
>>>> On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan
>>>> <[hidden email]> wrote:
>>>> > I keep getting error in import ICCProfile in PNGImagePlugin.py _save.
>>>> >
>>>> > What am I missing? Which package contains ICCProfile?
>>>>
>>>> Not sure why that code was left in there, but iirc it's an extension hook.
>>>>
>>>> > I've been searching but couldn't get a clue on why it is failing.
>>>>
>>>> Me neither, given that the import is protected by a try/except.
>>>>
>>>>   try:
>>>>       import ICCProfile
>>>>   except ImportError:
>>>>       ...
>>>>
>>>> What exactly are you doing when you get this import error, and what
>>>> does the full traceback look like?
>>>>
>>>> </F>
>>>
>>>
>>
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Bharathwaaj S-2
Hi,

I tried from the command line. Still getting error. Please see the log.

bharath@bharath-laptop:~/workspace/webKit$ python2.5
Python 2.5.5 (r255:77872, Nov  3 2010, 13:18:19)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> import ICCProfile
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ICCProfile
>>> from PIL import ICCProfile
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name ICCProfile
>>>

Kind regards,
Bharath

On 14 November 2010 09:14, Fredrik Lundh <[hidden email]> wrote:
So after digging a bit further, the suspect is the auto-reload
mechanisms in GAE's development appserver -- the appserver attempts to
clear out all imported modules in sys.modules when it detects changes
to your application code, and that process apparently leaves the PIL
modules in a half-baked state (i.e. "PIL" has been removed, but code
for "PIL.PngImagePlugin" is still around).

You're not importing PIL code directly, are you?

</F>

On Sat, Nov 13, 2010 at 3:17 PM, Fredrik Lundh <[hidden email]> wrote:
> By the way, I'm pretty sure that this only happens for some PNG
> images, and once you upload your application, PNG reading is done by
> GAE:s image library, not PIL, so the application you're building
> should be fine.
>
> </F>
>
> On Sat, Nov 13, 2010 at 2:40 PM, Fredrik Lundh <[hidden email]> wrote:
>> On Fri, Nov 12, 2010 at 10:33 PM, Bharathwaaj Srinivasan
>> <[hidden email]> wrote:
>>> I'm trying to get the images-demo working for google appengine.
>>>
>>> http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo
>>>
>>> The full traceback can be found here:
>>>
>>> http://pastebin.com/cBn6cA0V
>>
>> Hmm. First time I've ever seen that error in any context.  Looks like
>> GAE's import mechanisms cause some trouble for relative imports that
>> won't happen if you run things stand-alone.  And it looks like PIL's
>> far from the only library suffering from this:
>>
>> http://www.google.com/search?q=%22SystemError:+Parent+module+*+not+loaded%22
>>
>> even if most PIL reports I found seem to be for GAE.  My guess is that
>> it's some misfeature in the changes to relative import that was
>> introduced in 2.6 (iirc), but since it doesn't happen when you run PIL
>> in a normal configuration, I'm not sure how to debug it.  If someone
>> can come up with a simple test case that triggers this, let me know.
>>
>> I guess this also means that adding an ICCProfile module to the path
>> won't help you; if you cannot figure out something better, you might
>> have to comment out the problematic code (or you could try replacing
>> the relative import with a "from PIL import" and see if that helps).
>>
>> </F>
>>
>>> On 13 November 2010 02:04, Fredrik Lundh <[hidden email]> wrote:
>>>>
>>>> On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan
>>>> <[hidden email]> wrote:
>>>> > I keep getting error in import ICCProfile in PNGImagePlugin.py _save.
>>>> >
>>>> > What am I missing? Which package contains ICCProfile?
>>>>
>>>> Not sure why that code was left in there, but iirc it's an extension hook.
>>>>
>>>> > I've been searching but couldn't get a clue on why it is failing.
>>>>
>>>> Me neither, given that the import is protected by a try/except.
>>>>
>>>>   try:
>>>>       import ICCProfile
>>>>   except ImportError:
>>>>       ...
>>>>
>>>> What exactly are you doing when you get this import error, and what
>>>> does the full traceback look like?
>>>>
>>>> </F>
>>>
>>>
>>
>


_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Fredrik Lundh
On Sun, Nov 14, 2010 at 3:46 PM, Bharathwaaj Srinivasan
<[hidden email]> wrote:

> Hi,
>
> I tried from the command line. Still getting error. Please see the log.
>
> bharath@bharath-laptop:~/workspace/webKit$ python2.5
> Python 2.5.5 (r255:77872, Nov  3 2010, 13:18:19)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import PIL
>>>> import ICCProfile
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named ICCProfile
>>>> from PIL import ICCProfile
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: cannot import name ICCProfile
>>>>

That's irrelevant -- in the PNG module, the import is wrapped inside a
try/except statement.  The problem is that the try/except expects an
ImportError (which you'e seeing), not a SystemError (which is what
happens inside GAE).

</F>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Bharathwaaj S-2
As you suggested, I've commented out the try except code

        #try:
        #    import ICCProfile
        #    p = ICCProfile.ICCProfile(im.info["icc_profile"])
        #    name = p.tags.desc.get("ASCII", p.tags.desc.get("Unicode", p.tags.desc.get("Macintosh", p.tags.desc.get("en", {}).get("US", "ICC Profile")))).encode("latin1", "replace")[:79]
        #except ImportError:
        name = "ICC Profile"

and it works fine. Still couldn't understand why it was failing?

Kind regards,
Bharath

On 14 November 2010 22:26, Fredrik Lundh <[hidden email]> wrote:
On Sun, Nov 14, 2010 at 3:46 PM, Bharathwaaj Srinivasan
<[hidden email]> wrote:
> Hi,
>
> I tried from the command line. Still getting error. Please see the log.
>
> bharath@bharath-laptop:~/workspace/webKit$ python2.5
> Python 2.5.5 (r255:77872, Nov  3 2010, 13:18:19)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import PIL
>>>> import ICCProfile
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named ICCProfile
>>>> from PIL import ICCProfile
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: cannot import name ICCProfile
>>>>

That's irrelevant -- in the PNG module, the import is wrapped inside a
try/except statement.  The problem is that the try/except expects an
ImportError (which you'e seeing), not a SystemError (which is what
happens inside GAE).

</F>


_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Fredrik Lundh
I suspect a buglet in the GAE development server: when reloading the
code, it explicitly messes with sys.modules in a way that triggers
this error when PIL is invoked the next time (by calling code in a
module that no longer exists in sys.modules).  It only happens for
some PNG files, and only for PIL 1.1.7, so it hasn't shown up in their
tests yet.  And it doesn't happen in programs that doesn't manipulate
sys.modules directly (i.e. most programs), so we haven't seen it on
image-sig before.

</F>

On Sun, Nov 14, 2010 at 6:44 PM, Bharathwaaj Srinivasan
<[hidden email]> wrote:

> As you suggested, I've commented out the try except code
>
>         #try:
>         #    import ICCProfile
>         #    p = ICCProfile.ICCProfile(im.info["icc_profile"])
>         #    name = p.tags.desc.get("ASCII", p.tags.desc.get("Unicode",
> p.tags.desc.get("Macintosh", p.tags.desc.get("en", {}).get("US", "ICC
> Profile")))).encode("latin1", "replace")[:79]
>         #except ImportError:
>         name = "ICC Profile"
>
> and it works fine. Still couldn't understand why it was failing?
>
> Kind regards,
> Bharath
>
> On 14 November 2010 22:26, Fredrik Lundh <[hidden email]> wrote:
>>
>> On Sun, Nov 14, 2010 at 3:46 PM, Bharathwaaj Srinivasan
>> <[hidden email]> wrote:
>> > Hi,
>> >
>> > I tried from the command line. Still getting error. Please see the log.
>> >
>> > bharath@bharath-laptop:~/workspace/webKit$ python2.5
>> > Python 2.5.5 (r255:77872, Nov  3 2010, 13:18:19)
>> > [GCC 4.4.5] on linux2
>> > Type "help", "copyright", "credits" or "license" for more information.
>> >>>> import PIL
>> >>>> import ICCProfile
>> > Traceback (most recent call last):
>> >   File "<stdin>", line 1, in <module>
>> > ImportError: No module named ICCProfile
>> >>>> from PIL import ICCProfile
>> > Traceback (most recent call last):
>> >   File "<stdin>", line 1, in <module>
>> > ImportError: cannot import name ICCProfile
>> >>>>
>>
>> That's irrelevant -- in the PNG module, the import is wrapped inside a
>> try/except statement.  The problem is that the try/except expects an
>> ImportError (which you'e seeing), not a SystemError (which is what
>> happens inside GAE).
>>
>> </F>
>
>
_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Reply | Threaded
Open this post in threaded view
|

Re: import ICCProfile Error

Florian Höch
Hi,

the whole part

try:
     import ICCProfile
     ...
except ImportError:

is a leftover from development code. It can be removed with just leaving the

name = "ICC Profile"

without impeding any functionality (I contributed support for ICC
profile reading/writing a while back, and forgot to remove that part
back then). Sorry for the confusion caused.

Am 14.11.2010 20:06, schrieb Fredrik Lundh:

> I suspect a buglet in the GAE development server: when reloading the
> code, it explicitly messes with sys.modules in a way that triggers
> this error when PIL is invoked the next time (by calling code in a
> module that no longer exists in sys.modules).  It only happens for
> some PNG files, and only for PIL 1.1.7, so it hasn't shown up in their
> tests yet.  And it doesn't happen in programs that doesn't manipulate
> sys.modules directly (i.e. most programs), so we haven't seen it on
> image-sig before.
>
> </F>
>
> On Sun, Nov 14, 2010 at 6:44 PM, Bharathwaaj Srinivasan
> <[hidden email]>  wrote:
>> As you suggested, I've commented out the try except code
>>
>>          #try:
>>          #    import ICCProfile
>>          #    p = ICCProfile.ICCProfile(im.info["icc_profile"])
>>          #    name = p.tags.desc.get("ASCII", p.tags.desc.get("Unicode",
>> p.tags.desc.get("Macintosh", p.tags.desc.get("en", {}).get("US", "ICC
>> Profile")))).encode("latin1", "replace")[:79]
>>          #except ImportError:
>>          name = "ICC Profile"
>>
>> and it works fine. Still couldn't understand why it was failing?
>>
>> Kind regards,
>> Bharath
>>
>> On 14 November 2010 22:26, Fredrik Lundh<[hidden email]>  wrote:
>>>
>>> On Sun, Nov 14, 2010 at 3:46 PM, Bharathwaaj Srinivasan
>>> <[hidden email]>  wrote:
>>>> Hi,
>>>>
>>>> I tried from the command line. Still getting error. Please see the log.
>>>>
>>>> bharath@bharath-laptop:~/workspace/webKit$ python2.5
>>>> Python 2.5.5 (r255:77872, Nov  3 2010, 13:18:19)
>>>> [GCC 4.4.5] on linux2
>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>>> import PIL
>>>>>>> import ICCProfile
>>>> Traceback (most recent call last):
>>>>    File "<stdin>", line 1, in<module>
>>>> ImportError: No module named ICCProfile
>>>>>>> from PIL import ICCProfile
>>>> Traceback (most recent call last):
>>>>    File "<stdin>", line 1, in<module>
>>>> ImportError: cannot import name ICCProfile
>>>>>>>
>>>
>>> That's irrelevant -- in the PNG module, the import is wrapped inside a
>>> try/except statement.  The problem is that the try/except expects an
>>> ImportError (which you'e seeing), not a SystemError (which is what
>>> happens inside GAE).
>>>
>>> </F>
>>
>>
> _______________________________________________
> Image-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/image-sig

Regards
--
Florian Höch

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig