简体   繁体   中英

Centos 5 Python 2.7, Cannot install Python-LDAP

I need to install * Python-LDAP to run under Ptython 2.7

I have a Centos 5.8 system (I cannot upgrade to 6.x). I currently have Python 2.4 installed and also Python 2.7. I am using Python 2.7 for development (along with Django). I have Python-LDAP installed and working under Python 2.4 (it was installed using yum). I need to install Python-LDAP for use with Python 2.7 (I will also install Django-ldap). I have been trying for days to do this. yum only runs under Python 2.4 so I cannot use that. I downloaded the Python-LDAP source (python-ldap-2.4.13.tar.gz (md5) from https://pypi.python.org/pypi/python-ldap/ but when I try to build it I get errors (see below).

Does anyone know if/how I can install Python-LDAP for Python 2.7 on Centos 5?

Error while building:

python setup.py build

defines: HAVE_SASL HAVE_TLS HAVE_LIBLDAP_R
extra_compile_args:
extra_objects:
include_dirs: /home/sfuller/python-ldap-2.4.13 /usr/lib64/evolution-openldap/include 

/usr/lib/evolution-openldap/include /usr/include/sasl /usr/include library_dirs: /home/sfuller/python-ldap-2.4.13 /usr/lib64/evolution-openldap/lib64 /usr/lib /evolution-openldap/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 egg_info

....

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

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.13 -IModules -I/home/sfuller/python-ldap-2.4.13 -I/usr/lib64/evolution-openldap/include -I/usr /lib/evolution-openldap/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:0: /usr/include/sasl/sasl.h:349:5: warning: function declaration isnât a prototype [-Wstrict-prototypes]

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.13 -IModules -I/home/sfuller/python-ldap-2.4.13 -I/usr/lib64/evolution-openldap/include -I/usr/lib/evolution-openldap/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:5: warning: implicit declaration of function âldap_create_assertion_control_valueâ [-Wimplicit-function-declaration]

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.13 -IModules -I/home/sfuller/python-ldap-2.4.13 -I/usr/lib64/evolution-openldap/include -I/usr/lib/evolution-openldap/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.13 -IModules -I/home/sfuller/python-ldap-2.4.13 -I/usr/lib64/evolution-openldap/include -I/usr/lib/evolution-openldap/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:1: error: âLDAP_OPT_DIAGNOSTIC_MESSAGEâ undeclared (first use in 

this function) Modules/constants.c:155:1: note: each undeclared identifier is reported only once for each function it appears in Modules/constants.c:365:29: error: âLDAP_CONTROL_RELAXâ undeclared (first use in this function) error: command 'gcc' failed with exit status 1


I then looked over at this thread: https://mail.python.org/pipermail/python-ldap/2011q2/002937.html

So I downloaded the latest OpenLDAP and got:

./configure
Configuring OpenLDAP 2.4.38-Release ...
...
configure: error: BerkeleyDB version incompatible with BDB/HDB backends

Seems like I'm just sinking lower into a black hole...

This worked in centos 5.10 and python 2.7.6 . I installed into a virtualenv .

I see mentions of evolution-openldap in your logs which were in mine when I had the same issue. Those directories are installed by openldap 2.3x .

You don't need to build openldap from source as there is a version in yum that is new enough to satisfy the version requirement by python-ldap .

openldap24-libs.i386                 2.4.23-5.el5                     
openldap24-libs.x86_64               2.4.23-5.el5                     
openldap24-libs-devel.i386           2.4.23-5.el5                     
openldap24-libs-devel.x86_64         2.4.23-5.el5             

To install you should first yum install openldap24-libs openldap24-libs-devel .

edit setup.cfg so its [_ldap] section so it contains:

library_dirs = /usr/lib/openldap24
include_dirs = /usr/include/openldap24

Run the build again. (I deleted my old build/ directory, you probably don't need to but give that a shot if the above is not working).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM