【发布时间】:2020-01-19 17:37:02
【问题描述】:
我想在 Heroku 上使用 pdf2image,它是 python 包,它需要 poppler,所以我必须添加 poppler buildpack。
我添加了 https://github.com/survantjames/heroku-buildpack-poppler.git 并引用了 Install poppler onto Heroku Server django,但我的应用显示错误并崩溃。
所以我在 Heroku 上使用 bash 进行了检查,poppler 的 bin 目录路径添加了环境变量,但 poppler 实用程序失败并且不起作用。
pdfinfo(poppler utils之一)的错误信息是:
pdfinfo: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory
作为回应,我从https://elements.heroku.com/buildpacks/freddix/libpng12 添加了libpng12 buildpack,但它并没有改善。 如何在 Heroku 上使用 poppler buildpack?
构建包:
1. https://github.com/survantjames/heroku-buildpack-poppler.git
2. heroku/python
应用程序代码(python3):
from flask import Flask, Response
import pdf2image
import io
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello, World!'
@app.route('/img/')
def img():
img = pdf2image.convert_from_path(f'{app.root_path}/static/pdf/miku.pdf')[0]
buffer = io.BytesIO()
img.save(buffer, 'PNG')
return Response(buffer.getvalue(), mimetype='image/png')
if __name__ == '__main__':
app.run()
【问题讨论】:
标签: python python-3.x heroku buildpack poppler