Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install via pip in Alpine Linux 3.11 #61

Closed
3id010nCD opened this issue Apr 10, 2020 · 4 comments
Closed

Can't install via pip in Alpine Linux 3.11 #61

3id010nCD opened this issue Apr 10, 2020 · 4 comments

Comments

@3id010nCD
Copy link

Trying to install pdftotext==2.1.4 version.
There is a poppler package in Alpine repo, which includes poppler-dev, poppler-doc, poppler-glib, poppler-utils as subpackages...
My Dockerfile:

# precompiled python wheels for pandas and numpy => faster docker build
FROM nickgryg/alpine-pandas
# install dependencies
# the lapack package is only in the community repository
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
# Install dependencies
RUN apk add --no-cache --virtual .build-deps \
    gfortran \
    musl-dev \
    g++
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
RUN apk --update add --no-cache \
    freetype-dev \
    lapack-dev \
    gcc \
    poppler

COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt

# removing dependencies to limit the size of your image
RUN apk del .build-deps

Output with error:

Running setup.py install for pdftotext: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-envmib69/pdftotext/setup.py'"'"'; __file__='"'"'/tmp/pip-install-envmib69/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-record-6ng3cxtm/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/pdftotext
         cwd: /tmp/pip-install-envmib69/pdftotext/
    Complete output (12 lines):
    running install
    running build
    running build_ext
    building 'pdftotext' extension
    creating build
    creating build/temp.linux-x86_64-3.8
    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=0 -I/usr/local/include/python3.8 -c pdftotext.cpp -o build/temp.linux-x86_64-3.8/pdftotext.o -Wall
    pdftotext.cpp:3:10: fatal error: poppler/cpp/poppler-document.h: No such file or directory
        3 | #include <poppler/cpp/poppler-document.h>
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-envmib69/pdftotext/setup.py'"'"'; __file__='"'"'/tmp/pip-install-envmib69/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-record-6ng3cxtm/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/pdftotext Check the logs for full command output.

Maybe I need some additional packages?

@jalan
Copy link
Owner

jalan commented Apr 10, 2020

You also need to install the poppler-dev alpine package

@jalan jalan changed the title Can't install via pip in Alpine Linux 3.11 (within docker) Can't install via pip in Alpine Linux 3.11 Apr 13, 2020
@3id010nCD
Copy link
Author

Thank you! After installing poppler-dev, I could install correctly pdftotext python module. I, apparently, misunderstood official alpine repo page for poppler package. I thought poppler package already contains poppler-dev in Sub Packages...

@jalan jalan closed this as completed May 5, 2020
@gustawdaniel
Copy link

@jalan thank you. It saved me a lot of time! What do you think about presenting full recommended docker Image in docs?

I have this one

FROM python:3.7-alpine
WORKDIR /code
ENV FLASK_APP index.py
ENV FLASK_RUN_HOST 0.0.0.0
COPY requirements.txt requirements.txt
RUN apk add --no-cache --virtual \
      .build-deps \
      gcc \
      musl-dev \
      linux-headers \
      pkgconfig poppler-utils \
      build-base \
      alpine-sdk \
      poppler-dev \
     && pip install -r requirements.txt 
COPY . .
CMD ["flask", "run"]

Because of I connecting this with flask, but you better know which dependencies are really important.

@jalan
Copy link
Owner

jalan commented Aug 29, 2020

@gustawdaniel I like the idea here. I created #71 to track it, so I don't forget. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants