【发布时间】:2022-06-21 23:59:52
【问题描述】:
尝试在 Docker 映像中为 aws 安装 python-ldap 模块时出现以下错误:
In file included from Modules/LDAPObject.c:3:0:
Modules/common.h:15:10: fatal error: lber.h: No such file or directory
#include <lber.h>
^~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for python-ldap
Failed to build python-ldap
ERROR: Could not build wheels for python-ldap, which is required to install pyproject.toml-based projects
The command '/bin/sh -c pipenv lock -r > requirements.txt && pip install -r requirements.txt -t python' returned a non-zero code: 1
还有我的 Dockerfile:
FROM public.ecr.aws/lambda/python:3.8
ARG TMP_BUILD=/tmp
ARG DIST=/opt/build-dist
RUN yum makecache fast; yum clean all && yum -y update && yum -y upgrade; yum clean all && \
yum install -y yum-plugin-ovl; yum clean all && yum -y groupinstall "Development Tools"; yum clean all
RUN yum -y install gcc gcc-c++ make autoconf aclocal automake libtool python-devel openldap-devel; yum clean all && \
pip install --upgrade pip && pip install pipenv
WORKDIR ${TMP_BUILD}/build
COPY Pipfile .
COPY Pipfile.lock .
RUN pipenv lock -r > requirements.txt && \
pip install -r requirements.txt -t python
# && \
# find ./python -depth -path '*dist-info*' -delete && \
# find ./python -depth -path '*test*' -delete && \
# find ./python -depth -path '*pycache*' -delete
WORKDIR /opt
RUN mkdir -p ${DIST}/python && \
cp -rf ${TMP_BUILD}/build/python ${DIST} && \
cp -rf ${TMP_BUILD}/build/requirements.txt ${DIST}/requirements.txt
WORKDIR /var/task
这个构建直到最近都可以工作,你可以看到我有 python-devel openldap-devel 包,那么有什么问题?
在我运行 ManjaroLinux 的常规机器上安装此模块时也遇到了问题。我必须从源代码构建并手动更改二进制文件的名称。会不会是类似的情况?
如果有帮助,这里是 Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
slack-bolt = "*"
slack-sdk = "*"
aiohttp = "*"
python-ldap = "*"
[dev-packages]
black = "*"
boto3 = "*"
pytest = "*"
pytest-runner = "*"
pytest-mock = "*"
pandas = "*"
[requires]
python_version = "3.8"
[scripts]
lint = "pipenv run black . --check"
"lint:fix" = "pipenv run black ."
integrationtest = "pipenv run pytest . -m integration "
test = "pipenv run pytest . -m 'not integration' --ignore-glob='integration.py' --junitxml=./TEST-results-lambdas.xml"
[pipenv]
allow_prereleases = true
【问题讨论】:
-
您需要找到并安装包含缺少的头文件
lber.h的包。可能类似于libldap-dev的内容,尽管它可能是依赖项等的依赖项。(更新:packages.debian.org/… 建议libldap2-dev;但我现在看到你不在 Debian 上,所以你需要找到任何对你的发行版有用的东西。)当你解决了那个问题后,可能会有其他人遇到类似的问题。
标签: docker python-ldap