Docker python3.8 alpine 安装 python-ldap 失败,缺少 lber.h 文件。

huangapple go评论73阅读模式
英文:

Docker python3.8 alpine python-ldab installation fails missing lber.h

问题

I will provide the translated code segments as per your request. Here's the translated content:

FROM python:3.8.0-alpine

WORKDIR /home/flask
ADD . /home/flask

RUN apk --no-cache add --update --virtual .build-editdistance gcc g++ && \
    apk --no-cache add libsasl libldap openssl && \
    apk --no-cache add --update --virtual .libs libstdc++ && \
    apk add linux-headers && \
    apk add unixodbc-dev;

RUN rm -rf /var/cache/apk/* && \
    pip install --upgrade pip && \
    pip install --upgrade setuptools && \
    pip install --no-cache-dir -Ur requirements.txt && \
    apk del .build-editdistance;

EXPOSE 5000

Please let me know if you need further assistance or additional translations.

英文:

I am trying to pip install python-ldap in Docker but am missing lber.h. I need python-ldap because I am trying to implement an OS agnostic SSO for my application, following this for now and hoping it doesn't break the rest of my app https://code.tutsplus.com/tutorials/flask-authentication-with-ldap--cms-23101

I have tried

RUN apk add libsasl2-dev libldap2-dev libssl-dev

and

RUN apk --no-cache add libsasl2-dev libldap2-dev libssl-dev

but I get the following error:

ERROR: unsatisfiable constraints:
  libldap2-dev (missing):
    required by: world[libldap2-dev]
  libsasl2-dev (missing):
    required by: world[libsasl2-dev]
  libssl-dev (missing):
    required by: world[libssl-dev]

Having gone to https://pkgs.alpinelinux.org/packages?name=libldap2-dev&branch=edge I feel that it is possible that these packages do indeed not exist within the alpine python image. Therefore, I tried substituting the installations with packages that exist in the above link, namely: openssl libsasl libldap
This didn't work either and had the same effect as not installing any of the packages i.e. the header missing error appeared:

Modules/constants.h:7:10: fatal error: lber.h: No such file or directory

 #include "lber.h"
          ^~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

as a result of /tmp/pip-install-doifa8k9/python-ldap/

My Dockerfile:

    FROM python:3.8.0-alpine
     
    WORKDIR /home/flask
    ADD . /home/flask
     
    RUN apk --no-cache add --update --virtual .build-editdistance gcc g++ && \
        apk --no-cache add libsasl libldap openssl && \
        apk --no-cache add --update --virtual .libs libstdc++ && \
        apk add linux-headers && \
        apk add unixodbc-dev; 
        
    RUN rm -rf /var/cache/apk/* && \
        pip install --upgrade pip && \
        pip install --upgrade setuptools && \
        pip install --no-cache-dir -Ur requirements.txt && \
        apk del .build-editdistance;
        
    EXPOSE 5000

答案1

得分: 4

对于Alpine Python在Docker中的情况:

使用以下命令而不是:

这在https://stackoverflow.com/questions/4768446/i-cant-install-python-ldap中有答案,但答案被深埋并且被接受的答案所混淆(libsasl libldap openssl来自哪里),因此保留这个特定于Docker的问题是一个好主意。

英文:

For alpine python in docker:

apk add openldap-dev

instead of

apk add libsasl libldap openssl

This is answered in https://stackoverflow.com/questions/4768446/i-cant-install-python-ldap but the answer is buried sufficiently deep and obfuscated by the accepted answer ( which is where libsasl libldap openssl came from) that it would be a good idea to keep this docker specific question

huangapple
  • 本文由 发表于 2020年1月3日 21:53:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/59579789.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定