我无法安装 python-ldap
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4768446/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I can't install python-ldap
提问by VacuumTube
When I run the following command:
当我运行以下命令时:
sudo pip install python-ldap
I get this error:
我收到此错误:
In file included from Modules/LDAPObject.c:9:
Modules/errors.h:8: fatal error: lber.h: No such file or directory
在 Modules/LDAPObject.c:9 包含的文件中:
Modules/errors.h:8: 致命错误: lber.h: 没有那个文件或目录
Any ideas how to fix this?
任何想法如何解决这一问题?
采纳答案by AndiDog
The python-ldapis based on OpenLDAP, so you need to have the development files (headers) in order to compile the Python module. If you're on Ubuntu, the package is called libldap2-dev.
该蟒蛇,LDAP是基于OpenLDAP的,所以你必须为了编译Python模块的开发文件(头)。如果您使用的是 Ubuntu,则该软件包名为libldap2-dev.
Debian/Ubuntu:
Debian/Ubuntu:
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
RedHat/CentOS:
红帽/CentOS:
sudo yum install python-devel openldap-devel
回答by jmu
To install python-ldap successfully with pip, following development libraries are needed (package names taken from ubuntu environment):
要使用 pip 成功安装 python-ldap,需要以下开发库(包名取自 ubuntu 环境):
sudo apt-get install -y python-dev libldap2-dev libsasl2-dev libssl-dev
回答by Banjer
On CentOS/RHEL 6, you need to install:
在 CentOS/RHEL 6 上,您需要安装:
sudo yum install python-devel
sudo yum install openldap-devel
and yum will also install cyrus-sasl-develas a dependency. Then you can run:
yum 也将cyrus-sasl-devel作为依赖项安装。然后你可以运行:
pip-2.7 install python-ldap
回答by Jeff Sheffield
In Ubuntu it looks like this :
在 Ubuntu 中,它看起来像这样:
$ sudo apt-get install python-dev libldap2-dev libsasl2-dev libssl-dev
$ sudo pip install python-ldap
回答by Christian Berendt
On openSUSE you need to install the packages openldap2-devel, cyrus-sasl-devel, python-develand libopenssl-devel.
在openSUSE需要安装的软件包openldap2-devel,cyrus-sasl-devel,python-devel和libopenssl-devel。
zypper install openldap2-devel cyrus-sasl-devel python-devel libopenssl-devel
zypper install openldap2-devel cyrus-sasl-devel python-devel libopenssl-devel
回答by chfw
On Fedora 22, you need to do this instead:
在 Fedora 22 上,你需要这样做:
sudo dnf install python-devel
sudo dnf install openldap-devel
回答by archangel76
Windows: I completely agree with the accepted answer, but digging through the comments took a while to get to the meat of what I needed. I ran across this specific problem with Reviewboard on Windows using the Bitnami. To give an answer for windows then, I used this link mentioned in the comments:
Windows:我完全同意接受的答案,但挖掘评论需要一段时间才能找到我需要的内容。我使用 Bitnami 在 Windows 上的 Reviewboard 上遇到了这个特定问题。为了给出 Windows 的答案,我使用了评论中提到的这个链接:
- http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
- placed that wheel (whl file) into my reviewboard install directory
- http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
- 将该轮子(whl 文件)放入我的评论板安装目录中
Then, executed the following commands
然后,执行以下命令
easy_install pip
pip install python_ldap-2.4.20-cp27-none_win32.whl
(because I had python 2.7 and a 32bit install at that)
(因为我有 python 2.7 和 32 位安装)
easy_install python-ldap
回答by david.libremone
As a general solution to install Python packages with binary dependencies [1] on Debian/Ubuntu:
作为在 Debian/Ubuntu 上安装具有二进制依赖项 [1] 的 Python 包的通用解决方案:
sudo apt-get build-dep python-ldap
# installs system dependencies (but not the package itself)
pew workon my_virtualenv # enter your virtualenv
pip install python-ldap
You'll have to check the name of your Python package on Ubuntuversus PyPI. In this case they're the same.
您必须在 Ubuntu和 PyPI上检查Python 包的名称。在这种情况下,它们是相同的。
Obviously doesn't work if the Python package is not in the Ubuntu repos.
如果 Python 包不在 Ubuntu 存储库中,则显然不起作用。
[1] I learnt this trick when trying to pip install matplotlibon Ubuntu.
[1] 我pip install matplotlib在 Ubuntu 上尝试时学会了这个技巧。
回答by Andy Fraley
On OSX, you need the xcode CLI tools. Just open a terminal and run:
在 OSX 上,您需要 xcode CLI 工具。只需打开一个终端并运行:
xcode-select --install
回答by digitalr00ts
In FreeBSD 11:
在 FreeBSD 11 中:
pkg install openldap-client # for lber.h
pkg install cyrus-sasl # if you need sasl.h
pip install python-ldap

![Python IOError: [Errno 13] 权限被拒绝:](/res/img/loading.gif)