How do I install the correct dependences for Pillow on Heroku

14 Views Asked by At

A package (landingai) I'm using in my Heroku Flask app seems to require Pillow which in turn has external dependencies, so that when I first simply added the package to my app's requirements I got

RequiredDependencyException:
             
The headers or library files could not be found for zlib,
a required dependency when compiling Pillow from source.

I then did as advised and added the apt buildpack with

heroku buildpacks:add --index 1 heroku-community/apt

and added an Aptfile containing zlib (as zlib1g-dev) which eliminated the zlib error — as expected — but exposed a similar one for jpeg:

RequiredDependencyException:
             
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.

But adjusting my Aptfile to have the contents

zlib1g-dev
libjpeg8-dev

fails to fix the missing jpeg error as I would have expected.

How do I install the necessary dependences for Pillow on Heroku?


Note: adding all of the dependencies listed in the Pillow documentation to my Aptfile results in entirerhly different and obscure errors, FWIW:

             /usr/bin/ld: /tmp/build_89f994d5/.apt/usr/lib/x86_64-linux-gnu/libopenjp2.a(j2k.c.o): warning: relocation against `stdout@@GLIBC_2.2.5' in read-only section `.text'
             /usr/bin/ld: /tmp/build_89f994d5/.apt/usr/lib/x86_64-linux-gnu/libjpeg.a(jcapimin.c.o): relocation R_X86_64_PC32 against symbol `jpeg_natural_order' can not be used when making a shared object; recompile with -fPIC
0

There are 0 best solutions below