2012-07-30 152 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版本。