LDAP是轻量目录访问协议,英文全称是Lightweight Directory Access Protocol,一般都简称为LDAP,Windows 使用 pip 安装 python-ldap 时,提示找不到lber.h,本文介绍如何安装。

安装问题

pip install python-ldap

安装python-ldap提示找不到lber.h,错误日志:

c:\users\administrator\appdata\local\temp\pip-install-plurkp\python-ldap\modules\constants.h(7) : fatal error C1083: Cannot open include file: 'lber.h': No such file or directory
error: command 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

解决办法

安装 whl 包:https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap

$ pip install pyldap-2.4.45-cp27-cp27m-win32.whl
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Processing c:\users\administrator\downloads\pyldap-2.4.45-cp27-cp27m-win32.whl
Requirement already satisfied: setuptools in d:\pythonenv\blueking\lib\site-packages (from pyldap==2.4.45) (39.1.0)
Installing collected packages: pyldap
Successfully installed pyldap-2.4.45

pip install python_ldap-3.1.0-cp27-cp27m-win32.whl

完毕。