[Image-SIG] Re: ImportError: cannot import name PIL_Image

Gustavo González xtingray at linuxmail.org
Tue Dec 21 17:25:25 CET 2004


----- Original Message -----
From: "Fredrik Lundh" <fredrik at pythonware.com>
To: image-sig at python.org
Subject: [Image-SIG] Re: ImportError: cannot import name PIL_Image
Date: Tue, 21 Dec 2004 14:52:17 +0100

> 
> Gustavo González wrote:
> 
> >  ImportError: cannot import name PIL_Image
> >  File 
> > "/home/servicios/zope/raiz/Products/CMFReportTool/ReportTool.py", 
> > line 49, in ?
> >   from RenderPDF.Parser import TemplateParser,DocumentParser
> >  File 
> > "/home/servicios/zope/raiz/Products/CMFReportTool/RenderPDF/Parser.py", line 
> > 34, in ?
> >   from reportlab.lib.utils import PIL_Image
> > ImportError: cannot import name PIL_Image
> >
> > I installed the PIL before trying to start up the Zope server... 
> > and i can not
> > find any reference to the "PIL_Image" name... where should it be?

 
> it looks like it's a part of the reportlab library (see the "from" 
> part of the failing
> import statement).  that library is available here:
> 
>      http://www.reportlab.org/
 
  Hello! It was a problem in the CMFReportTool (Product for Zope) code.

  I fix it using a patch that i found here:
  http://sourceforge.net/mailarchive/forum.php?forum_id=12349&style=flat&viewday=20&viewmonth=200405

  This is the patch (i hope it can be useful for others):

--- CMFReportTool/RenderPDF/Parser.py.old       2004-02-18 04:44:16.000000000 +1300
+++ CMFReportTool/RenderPDF/Parser.py   2004-05-14 09:00:20.000000000 +1200
@@ -36,7 +36,8 @@
     from reportlab.lib.utils import PIL_Image
 except ImportError:
      # reportlab 1.19 compatibility
-    from reportlab.lib.utils import Image as PIL_Image
+    #from reportlab.lib.utils import Image as PIL_Image
+    from PIL import Image as PIL_Image
 import Platypus
 
 
@@ -448,6 +449,15 @@
             if "textcolor" in attr_names:
                 name = findAttrName(attr_names, "textColor")
                 obj.attributes["textColor"] = self.xml_ceval(node, name)
+
+            # Remove any attributes with a None value rather than override a
+            # default value.
+            # it would be better to not set them in the first place but the
+            # code will be cluttered
+            attributes = obj.attributes.keys()
+            for attr in attributes:
+                if obj.attributes[attr] is None:
+                    del obj.attributes[attr]
              
         elif node.nodeName == "tablestyle":
             name = self.xml_arg(node,"name")


===============================
 Gustavo González
 xtingray at linuxmail.org
===============================

-- 
______________________________________________
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze


More information about the Image-SIG mailing list