Openshift reportlab PIL issue

1k views Asked by At

I have successfully installed both PIL and reportlab in my cartridge (Python 2.7) and tested both of them via ssh in the console.

Somehow, reportlab can't use PIL.

I have also tried downloading PIL and fixing the 64bit issue, but I continue to get the error.

This the message I get:

unpack requires a string argument of length 1
Imaging Library not available, unable to import bitmaps only jpegs
fileName='/var/lib/openshift/52c1ab8de0b8cdb8a1000177/app-root/runtime/repo/wsgi/static/images/logo_colegio.png' identity=[ImageReader@0x7f6206c29c10 filename='/var/lib/openshift/52c1ab8de0b8cdb8a1000177/app-root/runtime/repo/wsgi/static/images/logo_colegio.png']
fileName='/var/lib/openshift/52c1ab8de0b8cdb8a1000177/app-root/runtime/repo/wsgi/static/images/logo_colegio.png' identity=[ImageReader@0x7f6206c29c10 filename='/var/lib/openshift/52c1ab8de0b8cdb8a1000177/app-root/runtime/repo/wsgi/static/images/logo_colegio.png']

I looked up the code and found this is where the exception should be thrown:

if haveImages:
    #detect which library we are using and open the image
    if not self._image:
        self._image = self._read_image(self.fp)
        if getattr(self._image,'format',None)=='JPEG': 
             self.jpeg_fh = self._jpeg_fh
else:
    from reportlab.pdfbase.pdfutils import readJPEGInfo
    try:
       self._width,self._height,c=readJPEGInfo(self.fp)
    except:
       annotateException('\nImaging Library not available, unable to import 

       bitmaps only jpegs\nfileName=%r identity=%s'%(fileName, self.identity()))

It should only raise if "haveImages" is False. Strangely enough, I used the console to print reportlab.util.haveImage and got "True"

I am running out of ideas... Has anyone encountered a situation like this? Any ideas will be appreciated!!

PD: This happens when I try to add an image to a Frame, using addFromList() ((Platypus))

1

There are 1 answers

0
Alvaro On BEST ANSWER

FOR ANYONE WITH THIS ISSUE:

The problem is pil just doesn't install properly on 64-bit systems. It isn't hard to edit the installation files. It is VERY IMPORTANT to restart your app after manually installing PIL