[reportlab-users] Reportlab/PIL and py2exe

Larry Bates reportlab-users@reportlab.com
Thu, 4 Mar 2004 16:40:27 -0600


I've been struggling to get Reportlab to work with py2exe.
Specifically the problem is that after a .PY file is 
"frozen" into .EXE any calls to Canvas.drawInlineImage
fail because ImageReader doesn't have the necessary
plugins to allow PIL.Image to determine the type of
image that is being placed on the Canvas.

I know the type of my images will either be .JPG or
.DCX so I inserted the following two lines at the 
the top of reportlab\lib\utils.py:

import PIL.DcxImagePlugin
import PIL.JpegImagePlugin

Note: importing these in my main program or in 
the class where I call Canvas.drawInlineImage
doesn't help.  For some reason they must be 
imported in utils.py.

This fixes my "specific" problem, but I was looking
for a more general solution (as well as one that
won't break when I install next version of Reportlab).

Is my problem a common one or is it too obscure to 
matter (I've encountered it a number of times in
other applications that I've attempted to run through
py2exe)?  Is there a better way to accomplish what
I have "hacked"?

Thanks in advance.

Regards, Larry