virtualenv python-ldap 安装错误

2023-12-27

请不要将此称为重复项。

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

示例包括:如何在 Ubuntu 上的 virtualenv 中安装 python-ldap? https://stackoverflow.com/questions/18134826/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 解决方案。

Thanks.


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

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

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

virtualenv python-ldap 安装错误 的相关文章

随机推荐