当我尝试在aws的Docker映像中安装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
以下作品-2022
apt-get install build-essential python3-dev libmemcached-dev libldap2-dev libsasl2-dev libzbar-dev ldap-utils tox lcov valgrind
样品:
FROM python:3.10-slim
RUN apt-get update &&
apt-get --yes install build-essential python3-dev libmemcached-dev libldap2-dev libsasl2-dev libzbar-dev ldap-utils tox lcov valgrind &&
apt-get clean
- 我遵循官方文档python-ldap:Debian在
sldap
安装和prumpt输入密码时卡住了 - 如果删除
sldap
,则表示:fatal error: libmemcached/memcached.h: No such file or directory
- 用
libmemcached-dev
代替sldap
后,问题得到了解决
Python依赖于一些软件包,为了安装它们,只需添加
RUN apt-get -y install libldap2-dev libsasl2-dev
在Dockerfile 上
(或yum install -y <package>
,根据您的示例(