首页 > 解决方案 > Docker 无法安装 python-ldap

问题描述

我有一个需要 LDAP 身份验证的 Python 烧瓶应用程序。我正在尝试为此创建一个 Docker 文件,但 docker build 失败并出现以下错误,

In file included from Modules/LDAPObject.c:8:
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

我已经安装了 python-ldap,pip install -r requirements.txt 也可以正常工作,但是 Docker 给出了错误。我有 Mac 操作系统。

我查找了以前的问题,发现您应该尝试安装依赖项,

sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev

但是如何在 Mac 中解决这个问题?

这是 DockerFile 的摘录,

运行 pip install -r requirements.txt

另外我没有使用虚拟环境。

标签: pythondockerldap

解决方案


尝试构建图像时是否失败?

如果是这样,那么您的 docker 映像似乎没有预装 gcc。尝试运行:

yum install gcc / python-devel

在尝试安装 python 包之前在你的 Dockerfile 中。


推荐阅读