gpt4 book ai didi

python-2.7 - virtualenv python-ldap安装错误

转载 作者:行者123 更新时间:2023-12-04 18:30:16 32 4
gpt4 key购买 nike

请不要将此称为重复项。

到目前为止,所有的答案都只是通过全局安装 ldap 和其他开发包来“解决”问题,这并不能解决无法在虚拟环境中安装 python-ldap 包的问题。

示例包括:
How do I install python-ldap in a virtualenv on Ubuntu?

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

我在我的虚拟环境中使用 ubuntu 14.04、python 2.7 和 flask 。

当我运行 pip install python-ldap ,我收到以下错误。
    copying Lib/ldap/schema/__init__.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/schema/models.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/schema/subentry.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/schema/tokenizer.py -> build/lib.linux-x86_64-2.7/ldap/schema
copying Lib/ldap/syncrepl.py -> build/lib.linux-x86_64-2.7/ldap
file Lib/ldap.py (for module ldap) not found
file Lib/ldap/controls.py (for module ldap.controls) not found
file Lib/ldap/extop.py (for module ldap.extop) not found
file Lib/ldap/schema.py (for module ldap.schema) not found
running egg_info
writing requirements to Lib/python_ldap.egg-info/requires.txt
writing Lib/python_ldap.egg-info/PKG-INFO
writing top-level names to Lib/python_ldap.egg-info/top_level.txt
writing dependency_links to Lib/python_ldap.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found

file Lib/ldap.py (for module ldap) not found
file Lib/ldap/controls.py (for module ldap.controls) not found
file Lib/ldap/extop.py (for module ldap.extop) not found
file Lib/ldap/schema.py (for module ldap.schema) not found
reading manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'Makefile'
warning: no files found matching 'Modules/LICENSE'
writing manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
running build_ext
building '_ldap' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/Modules
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.21 -IModules -I/usr/include -I/usr/include/sasl -I/usr/local/include -I/usr/local/include/sasl -I/usr/include/python2.7 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-2.7/Modules/LDAPObject.o
Modules/LDAPObject.c:18:18: fatal error: sasl.h: No such file or directory
#include <sasl.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Command "/home/kmertig/hd_request/hd_request/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-V4vhsl/python-ldap/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-NIR67Y-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kmertig/hd_request/hd_request/include/site/python2.7/python-ldap" failed with error code 1 in /tmp/pip-build-V4vhsl/python-ldap

如果我尝试 pip 安装任何建议的开发库,以便它们在我的虚拟环境中,我会收到以下错误。
  Could not find a version that satisfies the requirement libsasl2-dev (from versions: ) No matching distribution found for libsasl2-dev

我可以在全局范围内安装所有这些东西,但这完全违背了使用 virtualenv 的目的。

我真的很想找到一个有意义的 virtualenv 解决方案,因为我所能找到的只是针对 virtualenv 问题的非 virtualenv 解决方案。

谢谢。

最佳答案

Python 包 python-ldap 需要其他一些不是 python 库的库(libsasl2-dev,...)(因此您不能使用 pip 安装它们)。因此,要使用它们,您必须安装它们。两种解决方案:

  • 使用你的包管理器来安装它们(例如:apt-get);
  • 下载它们的源代码并在本地编译它们(在您的 virtualenv 中)(在特殊情况下对某些库很有用)。

  • 也许您可以尝试第二种解决方案?

    关于python-2.7 - virtualenv python-ldap安装错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33261983/

    32 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com