我无法安装 python-ldap

发布于 2024-10-13 02:07:02 字数 260 浏览 2 评论 0 原文

当我运行以下命令时:

sudo pip install python-ldap

我收到此错误:

在 Modules/LDAPObject.c:9 包含的文件中:

Modules/errors.h:8: 致命错误: lber.h: 没有这样的文件或目录

如何修复此问题?

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

How can I fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(27

攒眉千度 2024-10-20 02:07:03
sudo apt-get install build-essential python3-dev python2.7-dev libldap2-dev libsasl2-dev slapd ldap-utils python-tox lcov valgrind
sudo apt-get install build-essential python3-dev python2.7-dev libldap2-dev libsasl2-dev slapd ldap-utils python-tox lcov valgrind
丶情人眼里出诗心の 2024-10-20 02:07:03

对于 Arch Linux/Manjaro,对我来说,它对以下命令有帮助:

yay libldap24

For Arch Linux/Manjaro, for me, it helped with the following command:

yay libldap24
千秋岁 2024-10-20 02:07:03

在 OS X 上,您需要 Xcode CLI 工具。只需打开终端并运行:

xcode-select --install

On OS X, you need the Xcode CLI tools. Just open a terminal and run:

xcode-select --install
佼人 2024-10-20 02:07:03

Ubuntu

软件包 python-dev 已弃用或不再可用。你可以用这个代替:

sudo apt-get install libsasl2-dev python2-dev python2 python-dev-is-python3 libldap2-dev libssl-dev
pip install python-ldap

---编辑---
尝试安装 python-dev

Ubuntu

The package python-dev is deprecated or not longer available. You can use this instead:

sudo apt-get install libsasl2-dev python2-dev python2 python-dev-is-python3 libldap2-dev libssl-dev
pip install python-ldap

---Edit---
trying to install python-dev

乖乖哒 2024-10-20 02:07:03

作为在 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

您必须检查Ubuntu 上 Python 包的名称PyPI。在这种情况下它们是相同的。

显然,如果 Python 包不在 Ubuntu 存储库中,它就不起作用。

[1] 我在尝试在 Ubuntu 上pip install matplotlib 时学到了这个技巧。

As a general solution to install Python packages with binary dependencies 1 on Debian/Ubuntu:

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 Ubuntu versus PyPI. In this case they're the same.

Obviously, it doesn't work if the Python package is not in the Ubuntu repositories.

[1] I learnt this trick when trying to pip install matplotlib on Ubuntu.

三生殊途 2024-10-20 02:07:03

FreeBSD 11 中:

pkg install openldap-client # For lber.h
pkg install cyrus-sasl # If you need sasl.h
pip install python-ldap

In FreeBSD 11:

pkg install openldap-client # For lber.h
pkg install cyrus-sasl # If you need sasl.h
pip install python-ldap
世俗缘 2024-10-20 02:07:03

在构建Docker时安装python-ldap期间添加libzbar-dev也为我解决了这个问题。

完整的命令变为:

apt-get install -y python-dev libldap2-dev libsasl2-dev libssl-dev libzbar-dev

Also adding libzbar-dev during the installation of python-ldap when building Docker solved it for me.

The full command becomes:

apt-get install -y python-dev libldap2-dev libsasl2-dev libssl-dev libzbar-dev
旧城烟雨 2024-10-20 02:07:03

您需要安装 libldap2-dev (sudo apt-get install libldap2-dev),但 python-dev 也很重要。请记住使用您拥有的版本(sudo apt-get install python3.8-devsudo apt-get install pythonX.X-dev

You need to install libldap2-dev (sudo apt-get install libldap2-dev), but python-dev is also important. Remember to use the version you have (sudo apt-get install python3.8-dev or sudo apt-get install pythonX.X-dev)

む无字情书 2024-10-20 02:07:03

FreeBSD 13.1 的黑客答案(是的,我知道这是最佳实践的深处,但我只需要一个快速修复):

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

A hack answer for FreeBSD 13.1 (yes, I know this is deep South of best practices, but I just needed a quick fix):

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
烟若柳尘 2024-10-20 02:07:03

尝试:

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

Try:

ARCHFLAGS="-arch x86_64" pip3 install python-ldap
是伱的 2024-10-20 02:07:03

对于那些使用 Alpine Linux 的用户,

apk add openldap-dev

For those who are using Alpine Linux,

apk add openldap-dev
秋意浓 2024-10-20 02:07:03

如果您使用的是 Windows 计算机,则可以在 此链接,然后就可以安装它了。

If you're working with Windows machines, you can find the 'python-ldap' wheel in this link and then you can install it.

素罗衫 2024-10-20 02:07:02

python-ldap 基于 OpenLDAP,因此您需要按顺序准备开发文件(标头)编译Python模块。如果您使用的是 Ubuntu,则该软件包名为 libldap2-dev

Debian/Ubuntu:

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

红帽/CentOS

sudo yum install python-devel openldap-devel

The python-ldap is 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.

Debian/Ubuntu:

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

Red Hat/CentOS:

sudo yum install python-devel openldap-devel
半窗疏影 2024-10-20 02:07:02

要使用pip成功安装python-ldap,需要以下开发库(包名取自ubuntu环境):

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

To install python-ldap successfully with pip, following development libraries are needed (package names taken from ubuntu environment):

sudo apt-get install -y python-dev libldap2-dev libsasl2-dev libssl-dev
同尘 2024-10-20 02:07:02

CentOS/RHEL 6,您需要安装:

sudo yum install python-devel
sudo yum install openldap-devel

以及 YUM 还将安装 cyrus-sasl-devel 作为依赖项。然后你可以运行:

pip-2.7 install python-ldap

On CentOS/RHEL 6, you need to install:

sudo yum install python-devel
sudo yum install openldap-devel

And YUM will also install cyrus-sasl-devel as a dependency. Then you can run:

pip-2.7 install python-ldap
冰之心 2024-10-20 02:07:02

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

在基于 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-file search lber.h 的输出中看到的,您只需要安装包 libldap2-dev 即可。

sudo apt-get install libldap2-dev

"Don't blindly remove/install software"

In a Ubuntu or Debian-based distribution, you can use apt-file to find the name of the exact package that includes the missing header file.

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

apt-file search lber.h

Output:

libldap2-dev: /usr/include/lber.h

As you could see from the output of apt-file search lber.h, you'd just need to install the package libldap2-dev.

sudo apt-get install libldap2-dev
最冷一天 2024-10-20 02:07:02

在 Ubuntu 中它看起来像这样:

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

In Ubuntu it looks like this:

sudo apt-get install python-dev libldap2-dev libsasl2-dev libssl-dev
sudo pip install python-ldap
两相知 2024-10-20 02:07:02

Windows:我完全同意已接受的答案,但深入研究评论需要一段时间才能找到我需要的内容。我使用 Bitnami 在 Windows 上的 Reviewboard 中遇到了这个特定问题。为了给出 Windows 的答案,我使用了评论中提到的这个链接:

然后,执行以下命令

easy_install pip
pip install python_ldap-2.4.20-cp27-none_win32.whl

(因为我有 Python 2.7 和 32 位安装)

easy_install python-ldap

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:

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 32-bit install at that)

easy_install python-ldap
养猫人 2024-10-20 02:07:02

对于那些在 Alpine LinuxIber.h 的人>,在您尝试适应 Alpine 的 Docker 镜像中。

您正在寻找的软件包是:openldap-dev

因此运行

apk add openldap-dev

可从版本 3.3 到 Edge

适用于 armhf 和 x86_64 架构。

For those having the same issue of missing Iber.h on Alpine Linux, in a Docker image that you are trying to adapt to Alpine for instance.

The package you are looking for is: openldap-dev

So run

apk add openldap-dev

Available from version 3.3 up to Edge.

Available for both armhf and x86_64 Architectures.

婴鹅 2024-10-20 02:07:02

我在 Windows 上安装时遇到问题,因此解决方案之一是手动安装 ldap 软件包。

几个步骤:

  • 进入页面pyldap并下载最新版本<代码>*whl.

  • 打开控制台,然后 cd 到您下载文件(例如 some-package.whl)的位置并使用:

    pip install some-package.whl
    

pyldap 的当前版本是 2.4.45。在具体示例中,安装将是:

pip install .\pyldap-2.4.45-cp37-cp37m-win_amd64.whl

# Or
pip install .\python_ldap‑3.3.1‑cp39‑cp39‑win_amd64.whl

输出:

Installing collected packages: pyldap
Successfully installed pyldap-2.4.45

您可以使用以下命令安装 Python-3.X 的正确版本:

# If pip3 is the default pip alias for python-3
pip3 install python3-ldap

# Otherwise
pip install python3-ldap

此外,这里还有 PiPy 包的链接以获取更多信息: python3-ldap 0.9.8.4

ldap3 是严格符合 RFC 4510 的 LDAP V3 纯 Python 客户端库。相同的代码库在 Python 2、Python 3、PyPy 和 PyPy3 中运行: https://github.com/cannatag/ldap3

pip install ldap3
from ldap3 import Server, Connection, SAFE_SYNC

server = Server('my_server')
conn = Connection(server, 'my_user', 'my_password', client_strategy=SAFE_SYNC, auto_bind=True)

status, result, response, _ = conn.search('o=test', '(objectclass=*)')
# usually you don't need the original request (4th element of the returned tuple)

I had problems with the installation on Windows, so one of the solutions is to install the ldap package manually.

A few steps:

  • Go to the page pyldap and download the latest version *whl.

  • Open a console then cd to where you've downloaded your file like some-package.whl and use:

    pip install some-package.whl
    

The current version for pyldap is 2.4.45. On a concrete example the installation would be:

pip install .\pyldap-2.4.45-cp37-cp37m-win_amd64.whl

# Or
pip install .\python_ldap‑3.3.1‑cp39‑cp39‑win_amd64.whl

Output:

Installing collected packages: pyldap
Successfully installed pyldap-2.4.45

You can install the proper version for Python-3.X though using following command:

# If pip3 is the default pip alias for python-3
pip3 install python3-ldap

# Otherwise
pip install python3-ldap

Also here is the link of PiPy package for further information: python3-ldap 0.9.8.4

OR

ldap3 is a strictly RFC 4510 conforming LDAP V3 pure Python client library. The same codebase runs in Python 2, Python 3, PyPy and PyPy3: https://github.com/cannatag/ldap3

pip install ldap3
from ldap3 import Server, Connection, SAFE_SYNC

server = Server('my_server')
conn = Connection(server, 'my_user', 'my_password', client_strategy=SAFE_SYNC, auto_bind=True)

status, result, response, _ = conn.search('o=test', '(objectclass=*)')
# usually you don't need the original request (4th element of the returned tuple)
你与清晨阳光 2024-10-20 02:07:02

Fedora 22 上,您需要执行以下操作:

sudo dnf install python-devel
sudo dnf install openldap-devel

On Fedora 22, you need to do this instead:

sudo dnf install python-devel
sudo dnf install openldap-devel
千柳 2024-10-20 02:07:02

截至 2021 年 12 月,ldap 库曾经/现在存在一个奇怪的问题(至少在 Arch Linux/Manjaro)。

安装 python-ldap 时(在“Buildingwheel for python-ldap”处),我收到消息“ERROR: Failed Building Wheel for python-ldap”:

  /usr/bin/ld: cannot find -lldap_r
  collect2: error: ld returned 1 exit status
  error: command '/usr/bin/gcc' failed with exit code 1

支持 OpenLDAP 2.5+ #432

我引用:

作为解决方法,创建包含内容的文件 /usr/lib64/libldap_r.so
输入(libldap.so)。该方法适用于所有使用 GNU 的系统
ld 兼容链接器。

# cat > /usr/lib64/libldap_r.so << EOF
输入(libldap.so)
EOF

As of December 2021 there was/is a strange problem with the ldap library (at least in Arch Linux/Manjaro).

While installing python-ldap (at 'Building wheel for python-ldap'), I got the message 'ERROR: Failed building wheel for python-ldap':

  /usr/bin/ld: cannot find -lldap_r
  collect2: error: ld returned 1 exit status
  error: command '/usr/bin/gcc' failed with exit code 1

A workaround is provided at Support for OpenLDAP 2.5+ #432.

I cite:

As a workaround create the file /usr/lib64/libldap_r.so with content
INPUT ( libldap.so ). The approach works on all systems that use a GNU
ld-compatible linker.

# cat > /usr/lib64/libldap_r.so << EOF
INPUT ( libldap.so )
EOF
习ぎ惯性依靠 2024-10-20 02:07:02

对于 Alpine Docker

apk add openldap-dev

如果Python版本为3及以上,请尝试

pip install python3-ldap

For Alpine Docker:

apk add openldap-dev

If the Python version is 3 and above, try

pip install python3-ldap
最美的太阳 2024-10-20 02:07:02

Python 3 不支持python-ldap。而是安装ldap3

Python 3 does not support python-ldap. Rather install ldap3.

岁月染过的梦 2024-10-20 02:07:02

openSUSE 上,您需要安装软件包 openldap2-devel,<代码>cyrus-sasl-devel、python-devellibopenssl-devel

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

On openSUSE you need to install the packages openldap2-devel, cyrus-sasl-devel, python-devel and libopenssl-devel.

zypper install openldap2-devel cyrus-sasl-devel python-devel libopenssl-devel

把人绕傻吧 2024-10-20 02:07:02

要更正由于安装 python-ldap 的依赖项而导致的错误:Windows 7Windows 10

下载 whl 文件来自:

https:/ /github.com/cgohlke/python-ldap-build
(旧链接 http://www.lfd.uci.edu/~ gohlke/pythonlibs/#python-ldap 不再按照此处报告的方式工作)

Python 3.6 适合

python_ldap-3.2.0-cp36-cp36m-win_amd64.whl

将文件部署在:

C:\python36\Scripts\

安装它:

python -m pip install python_ldap-3.2.0-cp36-cp36m-win_amd64.whl

To correct the error due to dependencies to install the python-ldap: Windows 7 and Windows 10

Download the whl file from:

https://github.com/cgohlke/python-ldap-build
(old link http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap no longer working as reported here)

Python 3.6 suit with

python_ldap-3.2.0-cp36-cp36m-win_amd64.whl

Deploy the file in:

C:\python36\Scripts\

Install it with:

python -m pip install python_ldap-3.2.0-cp36-cp36m-win_amd64.whl
梦中楼上月下 2024-10-20 02:07:02

对于大多数系统,构建要求现在在 python-ldap 的文档,在“安装”部分。

如果您的系统缺少任何内容(或者您的系统完全丢失),请告知维护人员!
(截至 2018 年,我是维护者,所以这里的评论应该足够了。或者您可以发送拉取请求或邮件。)

For most systems, the build requirements are now mentioned in python-ldap's documentation, in the "Installing" section.

If anything is missing for your system (or your system is missing entirely), please let maintainer know!
(As of 2018, I am the maintainer, so a comment here should be enough. Or you can send a pull request or mail.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文