1

Hi i am unable to install ldap library in python 3.6. Command used is: pip install python-ldap

Error: pip install python-ldap Collecting python-ldap pip-install-snxkbc\python-ldap\ Using cached https://files.pythonhosted.org/packages/7f/1c/28d721dff2fcd2fef9d55b40df63a00be26ec8a11e8c6fc612ae642f9cfd/python-ldap-3.1.0.tar.gz Requirement already satisfied: pyasn1>=0.3.7 in c:\users\dm050767\python27\lib\site-packages (from python-ldap) (0.4.4) Requirement already satisfied: pyasn1_modules>=0.1.5 in c:\users\dm050767\python27\lib\site-packages (from python-ldap) (0.2.2) Building wheels for collected packages: python-ldap Running setup.py bdist_wheel for python-ldap ... error Complete output from command c:\users\dm050767\python27\python.exe -u -c "import setuptools, tokenize;file='c:\users\dm050767\appdata\local\temp\pip-install-snxkbc\python-ldap\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d c:\users\dm050767\appdata\local\temp\pip-wheel-kgoem3 --python-tag cp27: running bdist_wheel running build running build_py
creating build\lib.win32-2.7 copying Lib\ldapurl.py -> build\lib.win32-2.7 copying Lib\ldif.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\ldap copying Lib\ldap\async.py -> build\lib.win32-2.7\ldap copying Lib\ldap\asyncsearch.py -> build\lib.win32-2.7\ldap copying Lib\ldap\cidict.py -> build\lib.win32-2.7\ldap copying Lib\ldap\compat.py -> build\lib.win32-2.7\ldap copying Lib\ldap\constants.py -> build\lib.win32-2.7\ldap copying Lib\ldap\dn.py -> build\lib.win32-2.7\ldap copying Lib\ldap\filter.py -> build\lib.win32-2.7\ldap copying Lib\ldap\functions.py -> build\lib.win32-2.7\ldap copying Lib\ldap\ldapobject.py -> build\lib.win32-2.7\ldap copying Lib\ldap\logger.py -> build\lib.win32-2.7\ldap copying Lib\ldap\modlist.py -> build\lib.win32-2.7\ldap copying Lib\ldap\pkginfo.py -> build\lib.win32-2.7\ldap copying Lib\ldap\resiter.py -> build\lib.win32-2.7\ldap copying Lib\ldap\sasl.py -> build\lib.win32-2.7\ldap copying Lib\ldap\syncrepl.py -> build\lib.win32-2.7\ldap copying Lib\ldap__init__.py -> build\lib.win32-2.7\ldap creating build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\deref.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\libldap.py -> build\lib.win32-2.7\ldap\controls
copying Lib\ldap\controls\openldap.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\pagedresults.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\ppolicy.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\psearch.py -> build\lib.win32-2.7\ldap\controls
copying Lib\ldap\controls\pwdpolicy.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\readentry.py -> build\lib.win32-2.7\ldap\controls
copying Lib\ldap\controls\sessiontrack.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\simple.py -> build\lib.win32-2.7\ldap\controls
copying Lib\ldap\controls\sss.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\vlv.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls__init__.py -> build\lib.win32-2.7\ldap\controls creating build\lib.win32-2.7\ldap\extop copying Lib\ldap\extop\dds.py -> build\lib.win32-2.7\ldap\extop copying Lib\ldap\extop__init__.py -> build\lib.win32-2.7\ldap\extop creating build\lib.win32-2.7\ldap\schema copying Lib\ldap\schema\models.py -> build\lib.win32-2.7\ldap\schema copying Lib\ldap\schema\subentry.py -> build\lib.win32-2.7\ldap\schema copying Lib\ldap\schema\tokenizer.py -> build\lib.win32-2.7\ldap\schema
copying Lib\ldap\schema__init__.py -> build\lib.win32-2.7\ldap\schema creating build\lib.win32-2.7\slapdtest copying Lib\slapdtest_slapdtest.py -> build\lib.win32-2.7\slapdtest copying Lib\slapdtest__init__.py -> build\lib.win32-2.7\slapdtest 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 reading manifest file 'Lib\python_ldap.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'Doc.build' writing manifest file 'Lib\python_ldap.egg-info\SOURCES.txt' creating build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\README -> build\lib.win32-2.7\slapdtest\certs
copying Lib\slapdtest\certs\ca.conf -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\ca.pem -> build\lib.win32-2.7\slapdtest\certs
copying Lib\slapdtest\certs\client.conf -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\client.key -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\client.pem -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\gencerts.sh -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\gennssdb.sh -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\server.conf -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\server.key -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\server.pem -> build\lib.win32-2.7\slapdtest\certs running build_ext building '_ldap' extension creating build\temp.win32-2.7 creating build\temp.win32-2.7\Release
creating build\temp.win32-2.7\Release\Modules
C:\Users\dm050767\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=3.1.0 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -Ic:\users\dm050767\python27\include -Ic:\users\dm050767\python27\PC /TcModules/LDAPObject.c /Fobuild\temp.win32-2.7\Release\Modules/LDAPObject.obj LDAPObject.c c:\users\dm050767\appdata\local\temp\pip-install-snxkbc\python-ldap\modules\constants.h(7) : fatal error C1083: Cannot open include file: 'lber.h': No such file or directory error: command 'C:\Users\dm050767\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2

---------------------------------------- Failed building wheel for python-ldap Running setup.py clean for python-ldap Failed to build python-ldap Installing collected packages: python-ldap Running setup.py install for python-ldap ... error Complete output from command c:\users\dm050767\python27\python.exe -u -c "import setuptools, tokenize;file='c:\users\dm050767\appdata\local\temp\pip-install-snxkbc\python-ldap\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record c:\users\dm050767\appdata\local\temp\pip-record-uvc2cf\install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build\lib.win32-2.7 copying Lib\ldapurl.py -> build\lib.win32-2.7 copying Lib\ldif.py -> build\lib.win32-2.7 creating build\lib.win32-2.7\ldap copying Lib\ldap\async.py -> build\lib.win32-2.7\ldap copying Lib\ldap\asyncsearch.py -> build\lib.win32-2.7\ldap copying Lib\ldap\cidict.py -> build\lib.win32-2.7\ldap copying Lib\ldap\compat.py -> build\lib.win32-2.7\ldap copying Lib\ldap\constants.py -> build\lib.win32-2.7\ldap copying Lib\ldap\dn.py -> build\lib.win32-2.7\ldap copying Lib\ldap\filter.py -> build\lib.win32-2.7\ldap copying Lib\ldap\functions.py -> build\lib.win32-2.7\ldap copying Lib\ldap\ldapobject.py -> build\lib.win32-2.7\ldap copying Lib\ldap\logger.py -> build\lib.win32-2.7\ldap copying Lib\ldap\modlist.py -> build\lib.win32-2.7\ldap copying Lib\ldap\pkginfo.py -> build\lib.win32-2.7\ldap copying Lib\ldap\resiter.py -> build\lib.win32-2.7\ldap copying Lib\ldap\sasl.py -> build\lib.win32-2.7\ldap copying Lib\ldap\syncrepl.py -> build\lib.win32-2.7\ldap copying Lib\ldap__init__.py -> build\lib.win32-2.7\ldap creating build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\deref.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\libldap.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\openldap.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\pagedresults.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\ppolicy.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\psearch.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\pwdpolicy.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\readentry.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\sessiontrack.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\simple.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\sss.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls\vlv.py -> build\lib.win32-2.7\ldap\controls copying Lib\ldap\controls__init__.py -> build\lib.win32-2.7\ldap\controls creating build\lib.win32-2.7\ldap\extop copying Lib\ldap\extop\dds.py -> build\lib.win32-2.7\ldap\extop copying Lib\ldap\extop__init__.py -> build\lib.win32-2.7\ldap\extop creating build\lib.win32-2.7\ldap\schema copying Lib\ldap\schema\models.py -> build\lib.win32-2.7\ldap\schema copying Lib\ldap\schema\subentry.py -> build\lib.win32-2.7\ldap\schema copying Lib\ldap\schema\tokenizer.py -> build\lib.win32-2.7\ldap\schema copying Lib\ldap\schema__init__.py -> build\lib.win32-2.7\ldap\schema creating build\lib.win32-2.7\slapdtest copying Lib\slapdtest_slapdtest.py -> build\lib.win32-2.7\slapdtest copying Lib\slapdtest__init__.py -> build\lib.win32-2.7\slapdtest 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 reading manifest file 'Lib\python_ldap.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'Doc.build' writing manifest file 'Lib\python_ldap.egg-info\SOURCES.txt' creating build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\README -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\ca.conf -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\ca.pem -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\client.conf -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\client.key -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\client.pem -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\gencerts.sh -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\gennssdb.sh -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\server.conf -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\server.key -> build\lib.win32-2.7\slapdtest\certs copying Lib\slapdtest\certs\server.pem -> build\lib.win32-2.7\slapdtest\certs running build_ext building '_ldap' extension creating build\temp.win32-2.7 creating build\temp.win32-2.7\Release creating build\temp.win32-2.7\Release\Modules C:\Users\dm050767\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=3.1.0 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -Ic:\users\dm050767\python27\include -Ic:\users\dm050767\python27\PC /TcModules/LDAPObject.c /Fobuild\temp.win32-2.7\Release\Modules/LDAPObject.obj LDAPObject.c c:\users\dm050767\appdata\local\temp\pip-install-snxkbc\python-ldap\modules\constants.h(7) : fatal error C1083: Cannot open include file: 'lber.h': No such file or directory error: command 'C:\Users\dm050767\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2

---------------------------------------- Command "c:\users\dm050767\python27\python.exe -u -c "import setuptools,

tokenize;file='c:\users\dm050767\appdata\local\temp\pip-install-snxkbc\python-ldap\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record c:\users\dm050767\appdata\local\temp\pip-record-uvc2cf\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\dm050767\appdata\local\temp\pip-install-snxkbc\python-ldap\

3 Answers 3

1

For this you need to install dependencies required for Ubuntu/Debian are the following:

1)libldap2-dev

2)libsasl2-dev

3)slapd

4)ldap-utils

In my own case, I install it in my Dockerfile using the following command:

sudo apt-get update

sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libldap2-dev libsasl2-dev slapd ldap-utils

and finally, try to install LDAP by using

pip install django-auth-ldap

0

I suggest you download from the official source from Pypi repository (this too supports installing through pip)

$ python3 -m pip install python-ldap
2
  • error: [WinError 3] The system cannot find the path specified: 'C:\\Program
    – user10449598
    Commented Dec 6, 2018 at 8:42
  • (file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\dm050767\AppData\Local\Temp\pip-record-68gh24b2\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\dm050767\AppData\Local\Temp\pip-install-1nvbn842\python-ldap\
    – user10449598
    Commented Dec 6, 2018 at 8:42
0

On 2022-09-20, I was able to install the renamed package: ldap3 (formerly python-ldap) using (the trusted-host parameter is required by my org)

pip install ldap3 --trusted-host pypi.org

1
  • Rather than providing the date, consider providing package version etc to make the answer clearer. You can find more information on how to write good answers in the help center (stackoverflow.com/help/how-to-answer).
    – Jakob
    Commented Sep 24, 2022 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.