问题
pdftotext library is a requirement in requirements.txt. While trying to push to heroku, I get the following error:
remote: Running setup.py install for pdftotext: started
remote: Running setup.py install for pdftotext: finished with status 'error'
remote: Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-rnbekz45/pdftotext/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-o0if2tl3-record/install-record.txt --single-version-externally-managed --compile:
remote: /app/.heroku/python/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
remote: warnings.warn(msg)
remote: running install
remote: running build
remote: running build_ext
remote: building 'pdftotext' extension
remote: creating build
remote: creating build/temp.linux-x86_64-3.6
remote: gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=0 -I/app/.heroku/python/include/python3.6m -c pdftotext.cpp -o build/temp.linux-x86_64-3.6/pdftotext.o -Wall
remote: pdftotext.cpp:3:10: fatal error: poppler/cpp/poppler-document.h: No such file or directory
remote: #include <poppler/cpp/poppler-document.h>
remote: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
remote: compilation terminated.
remote: error: command 'gcc' failed with exit status 1
remote:
remote: ----------------------------------------
remote: Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-rnbekz45/pdftotext/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-o0if2tl3-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-rnbekz45/pdftotext/
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
Normally I'd solve this by installing libpoppler-cpp-dev
with apt
. But on heroku, I don't have root access to do that. Is there a solution for this?
I realize that strictly speaking, this isn't a programming question. But I need this to deploy my program, so I hope the purists here do forgive me.
回答1:
From How do I install additional software packages that my application requires?:
We don't offer official support for installing extra packages but there are a couple of unsupported options.
One is the experimental heroku-apt-buildpack. You can use this by including any APT package in an
Aptfile
in your application. The buildpack will then install these packages on the dyno when you deploy your application.
So, to do this, first add the build pack:
heroku buildpacks:add --index 1 heroku-community/apt
Then, create an Aptfile
in your source directory with the following contents:
libpoppler-cpp-dev
And deploy as you normally would. Let me know if that helps!
来源:https://stackoverflow.com/questions/54327005/installing-pdftotext-library-on-heroku