Search code examples
pythonheroku

Error while trying to use pdf2image on heroku : libpng12.so.0: cannot open shared object file: No such file or directory


I get the Exception: pdfinfo: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory

on the line images = pdf2image.convert_from_path("filename.pdf")

I tried adding this buildpack, but it didn't solve the problem.


Solution

  • had the same issue and solved it as follows:

    1. Remove the libpng buildback and the poppler utils buildback
    2. Create an Aptfile in the root directory of your project and add libpng-dev and poppler-utils to the file
    3. Add the official heroku api buildback heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
    4. Push a new version of your app to Heroku.