2012-07-30 119 views
0

我在将python ldap安装到单独的Python安装时遇到了一些问题。基本上Python2.4不应该被删除,因为系统(linux redhat)依赖于它,所以我将2.7安装在/srv/python2.7中的一个单独的位置。它看起来好像python-ldap已经安装了2.7,因为我可以在/srv/python2.7/bin/build/python-ldap中看到一些文件夹和文件。但是当我运行我的脚本时,它抱怨它无法找到ldap导入。当我尝试再次安装python ldap时,假设它没有正确安装,我在下面得到这个输出。我的意思是安装python ldap的所有先决条件都在系统上,例如python 2.4+,Openldap,sasl。安装python ldap以单独安装python

Python ldap适用于2.4,我可以看到/ usr/bin/build/python-ldap中的相关文件与/srv/python2.7/bin/build/python-ldap中的2.7相同。 。我还在脚本的顶部调用了正确的python解释器。并且还尝试使用pip来安装/srv/python2.7/bin/python/usr/bin/pip install python-ldap,但这也失败了。

[根@统计蟒-LDAP]#的/ usr/local/bin中/蟒的setup.py安装

defines: HAVE_SASL HAVE_TLS HAVE_LIBLDAP_R 
extra_compile_args: 
extra_objects: 
include_dirs: /opt/openldap-RE24/include /usr/include/sasl /usr/include 
library_dirs: /opt/openldap-RE24/lib /usr/lib 
libs: ldap_r 
running build 
running build_py 
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 
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 build_ext 
building '_ldap' extension 
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.10 -IModules -I/opt/openldap-RE24/include -I/usr/include/sasl -I/usr/include -I/usr/local/include/python2.7 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-2.7/Modules/LDAPObject.o 
In file included from Modules/LDAPObject.c:18: 
/usr/include/sasl/sasl.h:349: warning: function declaration isnât a prototype 
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.10 -IModules -I/opt/openldap-RE24/include -I/usr/include/sasl -I/usr/include -I/usr/local/include/python2.7 -c Modules/ldapcontrol.c -o build/temp.linux-x86_64-2.7/Modules/ldapcontrol.o 
Modules/ldapcontrol.c: In function âencode_assertion_controlâ: 
Modules/ldapcontrol.c:352: warning: implicit declaration of function âldap_create_assertion_control_valueâ 
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.10 -IModules -I/opt/openldap-RE24/include -I/usr/include/sasl -I/usr/include -I/usr/local/include/python2.7 -c Modules/common.c -o build/temp.linux-x86_64-2.7/Modules/common.o 
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.10 -IModules -I/opt/openldap-RE24/include -I/usr/include/sasl -I/usr/include -I/usr/local/include/python2.7 -c Modules/constants.c -o build/temp.linux-x86_64-2.7/Modules/constants.o 
Modules/constants.c: In function âLDAPinit_constantsâ: 
Modules/constants.c:155: error: âLDAP_OPT_DIAGNOSTIC_MESSAGEâ undeclared (first use in this function) 
Modules/constants.c:155: error: (Each undeclared identifier is reported only once 
Modules/constants.c:155: error: for each function it appears in.) 
Modules/constants.c:365: error: âLDAP_CONTROL_RELAXâ undeclared (first use in this function) 
error: command 'gcc' failed with exit status 1 

回答

0

这显然是要安装的蟒-LDAP版本和已安装的OpenLDAP之间的不匹配版。一般来说,你想安装最新的python-ldap与OpenLDAP体面的版本。狂猜:你的OpenLDAP安装太旧了。您可能想要在不同的路径中安装较新版本的OpenLDAP,并使用此版本重新编译python-ldap,或者搜索适合您安装的OpenLDAP版本的较早版本的python-ldap版本。