[Product-Developers] PIL/Pillow problem with openjpeg 2.1.0 [solved]

Dylan Jay djay at pretaweb.com
Tue May 13 01:01:05 UTC 2014


On 13 May 2014, at 1:54 am, Maurits van Rees <m.van.rees at zestsoftware.nl> wrote:

> Hi,
> 
> I suddenly got an error when starting up a previously fine working Plone site in the foreground:
> 
> Traceback (most recent call last):
>    ImportError: dlopen(.../Pillow-2.4.0-py2.7-macosx-10.4-x86_64.egg/PIL/_imaging.so, 2): Library not loaded: /opt/local/lib/libopenjp2.6.dylib
>  Referenced from: .../Pillow-2.4.0-py2.7-macosx-10.4-x86_64.egg/PIL/_imaging.so
>  Reason: image not found
> 
> This was Python 2.7 with Plone 4.3 and Pillow, but I had the same with Python 2.6 plus Plone 4.1 and PIL.
> 
> It turned out that I had recently updated my Mac ports and got openjpeg version 2.1.0.  Reverting to a previously installed version solved it:
> 
> sudo port activate openjpeg @2.0.0_1
> 
> (No recompilation of Pillow/PIL needed.)
> 
> I don't know if this is a problem in openjpeg, PIL, Mac ports, my Python buildout, or whatever.  But if you suddenly see an error like that, the above may help.

I tend to custom build libjpeg (like below) to try and avoid this issue. It mostly works but Pillow's setup.py seems to prefer system installed packages so not always.
I had to add a part to make it fail during buildout if Pillow isn't installed correctly in an attempt to make it more reliable.


[zlib]
recipe = zc.recipe.cmmi
url = ${urls:zlib}
depends-on = ${:url}

[urls]
libjpeg = http://www.ijg.org/files/jpegsrc.v8.tar.gz
libpng = http://prdownloads.sourceforge.net/libpng/libpng-1.5.12.tar.gz?download
libtiff = http://www.imagemagick.org/download/delegates/tiff-4.0.3.tar.gz
zlib = http://zlib.net/zlib-1.2.8.tar.gz

[libjpeg]
recipe = zc.recipe.cmmi
url = ${urls:libjpeg}
extra_options =
    --enable-static --enable-shared --with-jpeg8
#configure-options-darwin=--host x86_64-apple-darwin
depends-on = ${:url} ${:extra_options}

[libpng]
recipe = zc.recipe.cmmi
url = ${urls:libpng}
depends-on = ${:url}



[libtiff]
recipe = zc.recipe.cmmi
url = ${urls:libtiff}
#environment = CPPFLAGS=-I${libjpeg:location}/include -I${zlib:location}/include
#  LDFLAGS=-L${libjpeg:location}/lib -L${zlib:location}/lib -Wl,-rpath -Wl,${libjpeg:location}/lib -Wl,-rpath -Wl,${zlib:location}/lib
extra_options =
  --disable-static
  --without-x
  --disable-lzma
  --disable-jpeg
  --disable-zip
#environment =
#  CPPFLAGS=-I${libjpeg:location}/include  -I${zlib:location}/include
#  LDFLAGS=-L${libjpeg:location}/lib -Wl,-rpath=${libjpeg:location}/lib  -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib
depends-on = ${:url} ${libjpeg:depends-on} ${zlib:depends-on}

# WARNING: Pillow ignores these dependencies if it finds system versions https://github.com/python-imaging/Pillow/issues/542


[Pillow]
recipe = zc.recipe.egg:custom
egg = Pillow
include-dirs =
    ${zlib:location}/include
    ${libjpeg:location}/include
    ${libpng:location}/include
    ${libtiff:location}/include
library-dirs =
    ${zlib:location}/lib
    ${libjpeg:location}/lib
    ${libpng:location}/lib
    ${libtiff:location}/lib
rpath =
    ${zlib:location}/lib
    ${libjpeg:location}/lib
    ${libpng:location}/lib
    ${libtiff:location}/lib
environment = Pillow-env
#hack to force updating
depends-on = ${libjpeg:depends-on} ${libpng:depends-on} ${zlib:depends-on} ${libtiff:depends-on} rebuild1

[Pillow-env]
LD_RUN_PATH=${zlib:location}/lib:${libjpeg:location}/lib:${libpng:location}/lib:${libtiff:location}/lib
CPPFLAGS=
    -I${libjpeg:location}/include
    -I${zlib:location}/include
    -I${libpng:location}/inlcude
    -I${libtiff:location}/inlcude
LDFLAGS=
    -L${libjpeg:location}/lib
    -L${zlib:location}/lib
    -L${libpng:location}/lib
    -L${libtiff:location}/lib


# TODO: should be more comprehensive test. PIL comes with it's own built in test
[test-pillow]
recipe = plone.recipe.command >= 1.1
command = ${buildout:bin-directory}/${test-pillow-py:interpreter} -c 'from PIL import Image; Image.new("L", (100, 100)).save("test.jpg")'
update-command = ${:command}
stop-on-error = true

# if it fails, ensure it's built in develop-eggs
[test-pillow-py]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
interpreter = test-pillow-py






> 
> Best,
> 
> -- 
> Maurits van Rees: http://maurits.vanrees.org/
> Zest Software: http://zestsoftware.nl
> 
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> https://lists.plone.org/mailman/listinfo/plone-product-developers



More information about the Product-Developers mailing list