How can I install lxml in docker












13














I want to deploy my python project in docker, I wrote lxml>=3.5.0 in the requirments.txt as the project needs lxml. Here is my dockfile:



FROM gliderlabs/alpine:3.3
RUN set -x
&& buildDeps='
python-dev
py-pip
build-base
'
&& apk --update add python py-lxml $buildDeps
&& rm -rf /var/cache/apk/*
&& mkdir -p /app
ENV INSTALL_PATH /app
WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN pip install -r requirements.txt
COPY . .
RUN apk del --purge $buildDeps
ENTRYPOINT ["celery", "-A", "tasks", "worker", "-l", "info", "-B"]


I got this when I deploy it to docker:



*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of lxml


I though it was because 'python-dev' and 'python-lxml', then I edited the dockfile like this:



WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN apt-get build-dev python-lxml
RUN pip install -r requirements.txt


It did not work, and I got another error:



---> Running in 73201a0dcd59
/bin/sh: apt-get: not found


How can I install lxml correctly in docker? Thanks










share|improve this question


















  • 3




    You use alpine, so it may be apk add but not apt-get
    – user2915097
    Mar 11 '16 at 5:06










  • @user2915097 Thanks! I changed it to apk add python-dev py-lxml, it returned the error: error: command 'gcc' failed with exit status 1. I don't know how to install lxml
    – thiiiiiking
    Mar 11 '16 at 9:20










  • the package name is correct pkgs.alpinelinux.org/package/main/x86/py-lxml
    – user2915097
    Mar 11 '16 at 9:24






  • 1




    seems to install lxml fine in this Dockerfile pkgs.alpinelinux.org/package/main/x86/py-lxml or hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/… or hub.docker.com/r/trcook/docker-scrapy/builds/…
    – user2915097
    Mar 11 '16 at 9:26


















13














I want to deploy my python project in docker, I wrote lxml>=3.5.0 in the requirments.txt as the project needs lxml. Here is my dockfile:



FROM gliderlabs/alpine:3.3
RUN set -x
&& buildDeps='
python-dev
py-pip
build-base
'
&& apk --update add python py-lxml $buildDeps
&& rm -rf /var/cache/apk/*
&& mkdir -p /app
ENV INSTALL_PATH /app
WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN pip install -r requirements.txt
COPY . .
RUN apk del --purge $buildDeps
ENTRYPOINT ["celery", "-A", "tasks", "worker", "-l", "info", "-B"]


I got this when I deploy it to docker:



*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of lxml


I though it was because 'python-dev' and 'python-lxml', then I edited the dockfile like this:



WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN apt-get build-dev python-lxml
RUN pip install -r requirements.txt


It did not work, and I got another error:



---> Running in 73201a0dcd59
/bin/sh: apt-get: not found


How can I install lxml correctly in docker? Thanks










share|improve this question


















  • 3




    You use alpine, so it may be apk add but not apt-get
    – user2915097
    Mar 11 '16 at 5:06










  • @user2915097 Thanks! I changed it to apk add python-dev py-lxml, it returned the error: error: command 'gcc' failed with exit status 1. I don't know how to install lxml
    – thiiiiiking
    Mar 11 '16 at 9:20










  • the package name is correct pkgs.alpinelinux.org/package/main/x86/py-lxml
    – user2915097
    Mar 11 '16 at 9:24






  • 1




    seems to install lxml fine in this Dockerfile pkgs.alpinelinux.org/package/main/x86/py-lxml or hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/… or hub.docker.com/r/trcook/docker-scrapy/builds/…
    – user2915097
    Mar 11 '16 at 9:26
















13












13








13


2





I want to deploy my python project in docker, I wrote lxml>=3.5.0 in the requirments.txt as the project needs lxml. Here is my dockfile:



FROM gliderlabs/alpine:3.3
RUN set -x
&& buildDeps='
python-dev
py-pip
build-base
'
&& apk --update add python py-lxml $buildDeps
&& rm -rf /var/cache/apk/*
&& mkdir -p /app
ENV INSTALL_PATH /app
WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN pip install -r requirements.txt
COPY . .
RUN apk del --purge $buildDeps
ENTRYPOINT ["celery", "-A", "tasks", "worker", "-l", "info", "-B"]


I got this when I deploy it to docker:



*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of lxml


I though it was because 'python-dev' and 'python-lxml', then I edited the dockfile like this:



WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN apt-get build-dev python-lxml
RUN pip install -r requirements.txt


It did not work, and I got another error:



---> Running in 73201a0dcd59
/bin/sh: apt-get: not found


How can I install lxml correctly in docker? Thanks










share|improve this question













I want to deploy my python project in docker, I wrote lxml>=3.5.0 in the requirments.txt as the project needs lxml. Here is my dockfile:



FROM gliderlabs/alpine:3.3
RUN set -x
&& buildDeps='
python-dev
py-pip
build-base
'
&& apk --update add python py-lxml $buildDeps
&& rm -rf /var/cache/apk/*
&& mkdir -p /app
ENV INSTALL_PATH /app
WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN pip install -r requirements.txt
COPY . .
RUN apk del --purge $buildDeps
ENTRYPOINT ["celery", "-A", "tasks", "worker", "-l", "info", "-B"]


I got this when I deploy it to docker:



*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of lxml


I though it was because 'python-dev' and 'python-lxml', then I edited the dockfile like this:



WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN apt-get build-dev python-lxml
RUN pip install -r requirements.txt


It did not work, and I got another error:



---> Running in 73201a0dcd59
/bin/sh: apt-get: not found


How can I install lxml correctly in docker? Thanks







python docker lxml dockerfile






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 11 '16 at 3:19









thiiiiiking

4031615




4031615








  • 3




    You use alpine, so it may be apk add but not apt-get
    – user2915097
    Mar 11 '16 at 5:06










  • @user2915097 Thanks! I changed it to apk add python-dev py-lxml, it returned the error: error: command 'gcc' failed with exit status 1. I don't know how to install lxml
    – thiiiiiking
    Mar 11 '16 at 9:20










  • the package name is correct pkgs.alpinelinux.org/package/main/x86/py-lxml
    – user2915097
    Mar 11 '16 at 9:24






  • 1




    seems to install lxml fine in this Dockerfile pkgs.alpinelinux.org/package/main/x86/py-lxml or hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/… or hub.docker.com/r/trcook/docker-scrapy/builds/…
    – user2915097
    Mar 11 '16 at 9:26
















  • 3




    You use alpine, so it may be apk add but not apt-get
    – user2915097
    Mar 11 '16 at 5:06










  • @user2915097 Thanks! I changed it to apk add python-dev py-lxml, it returned the error: error: command 'gcc' failed with exit status 1. I don't know how to install lxml
    – thiiiiiking
    Mar 11 '16 at 9:20










  • the package name is correct pkgs.alpinelinux.org/package/main/x86/py-lxml
    – user2915097
    Mar 11 '16 at 9:24






  • 1




    seems to install lxml fine in this Dockerfile pkgs.alpinelinux.org/package/main/x86/py-lxml or hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/… or hub.docker.com/r/trcook/docker-scrapy/builds/…
    – user2915097
    Mar 11 '16 at 9:26










3




3




You use alpine, so it may be apk add but not apt-get
– user2915097
Mar 11 '16 at 5:06




You use alpine, so it may be apk add but not apt-get
– user2915097
Mar 11 '16 at 5:06












@user2915097 Thanks! I changed it to apk add python-dev py-lxml, it returned the error: error: command 'gcc' failed with exit status 1. I don't know how to install lxml
– thiiiiiking
Mar 11 '16 at 9:20




@user2915097 Thanks! I changed it to apk add python-dev py-lxml, it returned the error: error: command 'gcc' failed with exit status 1. I don't know how to install lxml
– thiiiiiking
Mar 11 '16 at 9:20












the package name is correct pkgs.alpinelinux.org/package/main/x86/py-lxml
– user2915097
Mar 11 '16 at 9:24




the package name is correct pkgs.alpinelinux.org/package/main/x86/py-lxml
– user2915097
Mar 11 '16 at 9:24




1




1




seems to install lxml fine in this Dockerfile pkgs.alpinelinux.org/package/main/x86/py-lxml or hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/… or hub.docker.com/r/trcook/docker-scrapy/builds/…
– user2915097
Mar 11 '16 at 9:26






seems to install lxml fine in this Dockerfile pkgs.alpinelinux.org/package/main/x86/py-lxml or hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/… or hub.docker.com/r/trcook/docker-scrapy/builds/…
– user2915097
Mar 11 '16 at 9:26














3 Answers
3






active

oldest

votes


















27














I added RUN apk add --update --no-cache g++ gcc libxslt-dev==1.1.29-r0 before RUN pip install -r requirements.txt and it worked.






share|improve this answer

















  • 8




    Just wanted to add that the release version of libxslt-dev is not necessary, you can do libxslt-dev.
    – Kazanz
    May 17 '17 at 19:59






  • 2




    I don't think that g++ is required for building libxml2 so I think that you can replace g++ with libc-dev which results in a smaller container for me.
    – Russell Gallop
    May 15 at 10:36



















-1














Actually, it's just



RUN apt-get install -y libxslt1-dev





share|improve this answer





























    -4














    Do as in



    https://hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/boinrrs9dbhnutwjxjw2l8m/



    Download the apk and install it




    RUN wget http://nl.alpinelinux.org/alpine/edge/main/x86_64/py-lxml-3.4.0-r0.apk -O /var/cache/apk/py-lxml.apk
    RUN apk add --allow-untrusted /var/cache/apk/py-lxml.apk






    share|improve this answer

















    • 5




      Just out of curiosity why was this downvoted so hard?
      – digitaldavenyc
      Dec 30 '16 at 4:19






    • 1




      @digitaldavenyc I didn't downvote; however, downloading an unauthenticated package and installing that as part of the build process does sound horrible to me.
      – marcelm
      Jul 25 at 15:24











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35931579%2fhow-can-i-install-lxml-in-docker%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    27














    I added RUN apk add --update --no-cache g++ gcc libxslt-dev==1.1.29-r0 before RUN pip install -r requirements.txt and it worked.






    share|improve this answer

















    • 8




      Just wanted to add that the release version of libxslt-dev is not necessary, you can do libxslt-dev.
      – Kazanz
      May 17 '17 at 19:59






    • 2




      I don't think that g++ is required for building libxml2 so I think that you can replace g++ with libc-dev which results in a smaller container for me.
      – Russell Gallop
      May 15 at 10:36
















    27














    I added RUN apk add --update --no-cache g++ gcc libxslt-dev==1.1.29-r0 before RUN pip install -r requirements.txt and it worked.






    share|improve this answer

















    • 8




      Just wanted to add that the release version of libxslt-dev is not necessary, you can do libxslt-dev.
      – Kazanz
      May 17 '17 at 19:59






    • 2




      I don't think that g++ is required for building libxml2 so I think that you can replace g++ with libc-dev which results in a smaller container for me.
      – Russell Gallop
      May 15 at 10:36














    27












    27








    27






    I added RUN apk add --update --no-cache g++ gcc libxslt-dev==1.1.29-r0 before RUN pip install -r requirements.txt and it worked.






    share|improve this answer












    I added RUN apk add --update --no-cache g++ gcc libxslt-dev==1.1.29-r0 before RUN pip install -r requirements.txt and it worked.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 27 '17 at 21:03









    Cintia Sestelo

    27933




    27933








    • 8




      Just wanted to add that the release version of libxslt-dev is not necessary, you can do libxslt-dev.
      – Kazanz
      May 17 '17 at 19:59






    • 2




      I don't think that g++ is required for building libxml2 so I think that you can replace g++ with libc-dev which results in a smaller container for me.
      – Russell Gallop
      May 15 at 10:36














    • 8




      Just wanted to add that the release version of libxslt-dev is not necessary, you can do libxslt-dev.
      – Kazanz
      May 17 '17 at 19:59






    • 2




      I don't think that g++ is required for building libxml2 so I think that you can replace g++ with libc-dev which results in a smaller container for me.
      – Russell Gallop
      May 15 at 10:36








    8




    8




    Just wanted to add that the release version of libxslt-dev is not necessary, you can do libxslt-dev.
    – Kazanz
    May 17 '17 at 19:59




    Just wanted to add that the release version of libxslt-dev is not necessary, you can do libxslt-dev.
    – Kazanz
    May 17 '17 at 19:59




    2




    2




    I don't think that g++ is required for building libxml2 so I think that you can replace g++ with libc-dev which results in a smaller container for me.
    – Russell Gallop
    May 15 at 10:36




    I don't think that g++ is required for building libxml2 so I think that you can replace g++ with libc-dev which results in a smaller container for me.
    – Russell Gallop
    May 15 at 10:36













    -1














    Actually, it's just



    RUN apt-get install -y libxslt1-dev





    share|improve this answer


























      -1














      Actually, it's just



      RUN apt-get install -y libxslt1-dev





      share|improve this answer
























        -1












        -1








        -1






        Actually, it's just



        RUN apt-get install -y libxslt1-dev





        share|improve this answer












        Actually, it's just



        RUN apt-get install -y libxslt1-dev






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 at 2:23









        Pablo Morales

        457412




        457412























            -4














            Do as in



            https://hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/boinrrs9dbhnutwjxjw2l8m/



            Download the apk and install it




            RUN wget http://nl.alpinelinux.org/alpine/edge/main/x86_64/py-lxml-3.4.0-r0.apk -O /var/cache/apk/py-lxml.apk
            RUN apk add --allow-untrusted /var/cache/apk/py-lxml.apk






            share|improve this answer

















            • 5




              Just out of curiosity why was this downvoted so hard?
              – digitaldavenyc
              Dec 30 '16 at 4:19






            • 1




              @digitaldavenyc I didn't downvote; however, downloading an unauthenticated package and installing that as part of the build process does sound horrible to me.
              – marcelm
              Jul 25 at 15:24
















            -4














            Do as in



            https://hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/boinrrs9dbhnutwjxjw2l8m/



            Download the apk and install it




            RUN wget http://nl.alpinelinux.org/alpine/edge/main/x86_64/py-lxml-3.4.0-r0.apk -O /var/cache/apk/py-lxml.apk
            RUN apk add --allow-untrusted /var/cache/apk/py-lxml.apk






            share|improve this answer

















            • 5




              Just out of curiosity why was this downvoted so hard?
              – digitaldavenyc
              Dec 30 '16 at 4:19






            • 1




              @digitaldavenyc I didn't downvote; however, downloading an unauthenticated package and installing that as part of the build process does sound horrible to me.
              – marcelm
              Jul 25 at 15:24














            -4












            -4








            -4






            Do as in



            https://hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/boinrrs9dbhnutwjxjw2l8m/



            Download the apk and install it




            RUN wget http://nl.alpinelinux.org/alpine/edge/main/x86_64/py-lxml-3.4.0-r0.apk -O /var/cache/apk/py-lxml.apk
            RUN apk add --allow-untrusted /var/cache/apk/py-lxml.apk






            share|improve this answer












            Do as in



            https://hub.docker.com/r/ryanfox1985/docker-couchpotato/builds/boinrrs9dbhnutwjxjw2l8m/



            Download the apk and install it




            RUN wget http://nl.alpinelinux.org/alpine/edge/main/x86_64/py-lxml-3.4.0-r0.apk -O /var/cache/apk/py-lxml.apk
            RUN apk add --allow-untrusted /var/cache/apk/py-lxml.apk







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 11 '16 at 9:52









            user2915097

            12.6k32839




            12.6k32839








            • 5




              Just out of curiosity why was this downvoted so hard?
              – digitaldavenyc
              Dec 30 '16 at 4:19






            • 1




              @digitaldavenyc I didn't downvote; however, downloading an unauthenticated package and installing that as part of the build process does sound horrible to me.
              – marcelm
              Jul 25 at 15:24














            • 5




              Just out of curiosity why was this downvoted so hard?
              – digitaldavenyc
              Dec 30 '16 at 4:19






            • 1




              @digitaldavenyc I didn't downvote; however, downloading an unauthenticated package and installing that as part of the build process does sound horrible to me.
              – marcelm
              Jul 25 at 15:24








            5




            5




            Just out of curiosity why was this downvoted so hard?
            – digitaldavenyc
            Dec 30 '16 at 4:19




            Just out of curiosity why was this downvoted so hard?
            – digitaldavenyc
            Dec 30 '16 at 4:19




            1




            1




            @digitaldavenyc I didn't downvote; however, downloading an unauthenticated package and installing that as part of the build process does sound horrible to me.
            – marcelm
            Jul 25 at 15:24




            @digitaldavenyc I didn't downvote; however, downloading an unauthenticated package and installing that as part of the build process does sound horrible to me.
            – marcelm
            Jul 25 at 15:24


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f35931579%2fhow-can-i-install-lxml-in-docker%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python