执行以下命令时:

sudo pip install python-ldap

我得到这个错误:

在Modules/LDAPObject.c:9包含的文件中: Modules/errors.h:8:致命错误:lber.h:没有这样的文件或目录

有什么解决办法吗?


当前回答

sudo apt-get install build-essential python3-dev python2.7-dev libldap2-dev libsasl2-dev slapd ldap-utils python-tox lcov valgrind

Debian参考: https://www.python-ldap.org/en/latest/installing.html#debian 其他信息:https://www.python-ldap.org/en/latest/installing.html

其他回答

在openSUSE上需要安装openldap2-devel、cyrus-sasl-devel、python-devel和libopenssl-devel。

Zypper安装openldap2-devel cyrus-sasl-devel python-devel libopenssl-devel

对FreeBSD 13.1的一个hack答案(是的,我知道这是最佳实践的深层南方,但我只是需要一个快速修复):

pkg install openldap24-client

cd /usr/local/include/python3.9
ln -s ../<all of the below> .

lber.h
lber_types.h
ldap.h
ldap_cdefs.h
ldap_features.h
ldap_schema.h
ldap_utf8.h
openldap.h
sasl

pip install python-ldap

在Ubuntu中,它是这样的:

 $ sudo apt-get install python-dev libldap2-dev libsasl2-dev libssl-dev
 $ sudo pip install python-ldap

try:

ARCHFLAGS="-arch x86_64" pip3 install python-ldap

“不要盲目地删除/安装软件”

在基于Ubuntu或Debian的发行版中,您可以使用apt-file来查找包含丢失头文件的确切包的名称。

# do this once
sudo apt-get install apt-file
sudo apt-file update

$ apt-file search lber.h
libldap2-dev: /usr/include/lber.h

正如您可以从apt文件搜索lber.h的输出中看到的,您只需要安装包libldap2-dev。

sudo apt-get install libldap2-dev