Reputation: 37
I'm deploying an app which is using pdf2image to gcp app engine. When I wanted to test it I got an error:
pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
I found this post and added dockerfile to my project, this is how it looks:
FROM gcr.io/google-appengine/python
# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.
# Use -p python3 or -p python3.7 to select python version. Default is version 2.
RUN apt-get install poppler-utils
RUN virtualenv -p python3.7 /env
# Setting these environment variables are the same as running
# source /env/bin/activate.
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.
ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
# Add the application source code.
ADD . /app
# Run a WSGI server to serve the application. gunicorn must be declared as
# a dependency in requirements.txt.
CMD gunicorn -b :$PORT main:app
I also changed the app.yaml file:
runtime: custom
env: flex
And now when I try to deploy the app I get:
Step 2/9 : RUN apt-get install poppler-utils
---> Running in db1e5bebd0a8
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package poppler-utils
The command '/bin/sh -c apt-get install poppler-utils' returned a non-zero code: 100
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: exit status 100
I also tried python-poppler instead of poppler-utils and got the same error.
I found this post about installing poppler and now I'm wondering if I can do this in dockerfile, I haven't work with docker before, this was my first dockerfile.
Upvotes: 3
Views: 8760
Reputation: 3192
You should fetch the package with apt-get update
before installing it, otherwise the package manager won't find it and throw this error.
As well, installing the package will require you to confirm the installation by typing Y/n
in a prompt, which you won't be able to do in a Dockerfile. To avoid this, add the flag -y
to the apt-get install
command.
Adding this changes to your Dockerfile would look like this:
FROM gcr.io/google-appengine/python
RUN apt-get update
RUN apt-get install poppler-utils -y
RUN virtualenv -p python3.7 /env
# Rest of your build steps...
Upvotes: 14