別の Python インストールに python ldap をインストールする際に問題が発生しました。基本的に、システム (linux redhat) が Python2.4 に依存しているため、Python2.4 は削除しないでください。別の場所の /srv/python2.7 に 2.7 をインストールしました。/srv/python2.7/bin/build/python-ldap にいくつかのフォルダーとファイルが表示されるため、2.7 用の python-ldap が既にインストールされているように見えます。しかし、スクリプトを実行すると、ldap インポートが見つからないというエラーが表示されます。適切にインストールされていないと仮定して、python ldap を再度インストールしようとすると、以下の出力が得られます。つまり、python ldap をインストールするための前提条件はすべて、python 2.4+、Openldap、sasl などのシステム上にあります。
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 をインストールしようとしましたが、これも惨めに失敗しました。
[root@stats python-ldap]# /usr/local/bin/python 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