简体   繁体   中英

pdf2image not working with gunicorn/flask

For the past day I have been trying to incorporate pdf2image into my flask webservice. The problem is, whatever I do, I still get the "Is poppler installed and in PATH?" error message. I have written a little program that just prints the number of pages in a pdf file. This works completely fine, inside and outside the venv containing flask. If I try to do this from the flask file, I get the error. I even tried calling the very same function in the test code, but to no avail. I don't really know what to do anymore, so any help is greatly appreciated.

PS: I don't really know what source to include for this post, so just feel free to ask and I will provide it.

I had the symptoms which you describe. For me the problem was the following:

in the .service file used by systemd to start gunicorn, I had an incomplete path variable. The solution was to add the path to pdftoppm and pdftocairo, which in my case (on Debian 10) was /usr/bin The solution is therefore that the .service file includes

[Service]
...
Environment="PATH=<your_app_path>/venv/bin:/usr/bin"

Note: This problem and its solution are thus broader than a pdf2image issue, but it seems to show up frequently with pdf2image... assuming this is true, I hope that your question and my response are both relevant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM