I’m getting the following error when trying to install python-ldap module in Docker image for aws:
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
And my 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
This build used to work until recently and as you can see i have the python-devel openldap-devel packages so what’s the problem?
Was also having trouble installing this module on my regular machine which runs ManjaroLinux. I had to build from source and change the name of a binary file manually. Could this be a similar situation?
Here is the Pipfile if it helps
[[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
2
Answers
Python relies on some packages to be present, in order to have them installed just add
on your Dockerfile
(or
yum install -y <package>
as per your example)Below works – 2022
apt-get install build-essential python3-dev libmemcached-dev libldap2-dev libsasl2-dev libzbar-dev ldap-utils tox lcov valgrind
Sample:
sldap
installation and prumpt input password.sldap
it said:fatal error: libmemcached/memcached.h: No such file or directory
sldap
withlibmemcached-dev
problem solved.