简体   繁体   中英

Error Installing python-ldap package

I'm trying to install the python-ldap package with PyCharm and it is not working out, i get the following error:

在此处输入图片说明

Error Message:

Collecting python-ldap Using cached https://files.pythonhosted.org/packages/7f/1c/28d721dff2fcd2fef9d55b40df63a00be26ec8a11e8c6fc612ae642f9cfd/python-ldap-3.1.0.tar.gz Collecting pyasn1>=0.3.7 (from python-ldap) Using cached https://files.pythonhosted.org/packages/a0/70/2c27740f08e477499ce19eefe05dbcae6f19fdc49e9e82ce4768be0643b9/pyasn1-0.4.3-py2.py3-none-any.whl Collecting pyasn1_modules>=0.1.5 (from python-ldap) Using cached https://files.pythonhosted.org/packages/e9/51/bcd96bf6231d4b2cc5e023c511bee86637ba375c44a6f9d1b4b7ad1ce4b9/pyasn1_modules-0.2.1-py2.py3-none-any.whl Installing collected packages: pyasn1, pyasn1-modules, python-ldap Running setup.py install for python-ldap: started Running setup.py install for python-ldap: finished with status 'error' Complete output from command C:\\Users\\Joan\\PycharmProjects\\prueba\\venv\\Scripts\\python.exe -u -c "import setuptools, tokenize; file ='C:\\Users\\Joan\\AppData\\Local\\Temp\\pycharm-packaging\\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\\Joan\\AppData\\Local\\Temp\\pip-record-y2ot_u84\\install-record.txt --single-version-externally-managed --compile --install-headers C:\\Users\\Joan\\PycharmProjects\\prueba\\venv\\include\\site\\python3.6\\python-ldap: running install running build running build_py creating build\\lib.win-amd64-3.6 copying Lib\\ldapurl.py -> build\\lib.win-amd64-3.6 copying Lib\\ldif.py -> build\\lib.win-amd64-3.6 creating build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\async.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\asyncsearch.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\cidict.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\compat.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\constants.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\dn.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\filter.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\functions.py -> build\\l ib.win-amd64-3.6\\ldap copying Lib\\ldap\\ldapobject.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\logger.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\modlist.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\pkginfo.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\resiter.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\sasl.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap\\syncrepl.py -> build\\lib.win-amd64-3.6\\ldap copying Lib\\ldap__init__.py -> build\\lib.win-amd64-3.6\\ldap creating build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\deref.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\libldap.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\openldap.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\pagedresults.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\ppolicy.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\psearch.py -> build\\lib.win-amd 64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\pwdpolicy.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\readentry.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\sessiontrack.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\simple.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\sss.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls\\vlv.py -> build\\lib.win-amd64-3.6\\ldap\\controls copying Lib\\ldap\\controls__init__.py -> build\\lib.win-amd64-3.6\\ldap\\controls creating build\\lib.win-amd64-3.6\\ldap\\extop copying Lib\\ldap\\extop\\dds.py -> build\\lib.win-amd64-3.6\\ldap\\extop copying Lib\\ldap\\extop__init__.py -> build\\lib.win-amd64-3.6\\ldap\\extop creating build\\lib.win-amd64-3.6\\ldap\\schema copying Lib\\ldap\\schema\\models.py -> build\\lib.win-amd64-3.6\\ldap\\schema copying Lib\\ldap\\schema\\subentry.py -> build\\lib.win-amd64-3.6\\ldap\\schema copying Lib\\ldap\\schema\\tokenizer.py -> build\\lib.win-am d64-3.6\\ldap\\schema copying Lib\\ldap\\schema__init__.py -> build\\lib.win-amd64-3.6\\ldap\\schema creating build\\lib.win-amd64-3.6\\slapdtest copying Lib\\slapdtest_slapdtest.py -> build\\lib.win-amd64-3.6\\slapdtest copying Lib\\slapdtest__init__.py -> build\\lib.win-amd64-3.6\\slapdtest running egg_info writing Lib\\python_ldap.egg-info\\PKG-INFO writing dependency_links to Lib\\python_ldap.egg-info\\dependency_links.txt writing requirements to Lib\\python_ldap.egg-info\\requires.txt writing top-level names to Lib\\python_ldap.egg-info\\top_level.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.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\README -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\ca.conf -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\ca .pem -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\client.conf -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\client.key -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\client.pem -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\gencerts.sh -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\gennssdb.sh -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\server.conf -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\server.key -> build\\lib.win-amd64-3.6\\slapdtest\\certs copying Lib\\slapdtest\\certs\\server.pem -> build\\lib.win-amd64-3.6\\slapdtest\\certs warning: build_py: byte-compiling is disabled, skipping.

running build_ext
building '_ldap' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\Modules
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -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\Joan\PycharmProjects\prueba\venv\include -IC:\Users\Joan\AppData\Local\Programs\Python\Python36\include -IC:\Users\Joan\AppData\Local\Programs\Python\Python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcModules/LDAPObject.c /Fobuild\temp.win-amd64-3.6\Release\Modules/LDAPObject.obj
LDAPObject.c
c:\users\joan\appdata\local\temp\pycharm-packaging\python-ldap\modules\constants.h(7): fatal error C1083: Cannot open include file: 'lber.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

----------------------------------------

Command "C:\\Users\\Joan\\PycharmProjects\\prueba\\venv\\Scripts\\python.exe -u -c "import setuptools, tokenize; file ='C:\\Users\\Joan\\AppData\\Local\\Temp\\pycharm-packaging\\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\\Joan\\AppData\\Local\\Temp\\pip-record-y2ot_u84\\install-record.txt --single-version-externally-managed --compile --install-headers C:\\Users\\Joan\\PycharmProjects\\prueba\\venv\\include\\site\\python3.6\\python-ldap" failed with error code 1 in C:\\Users\\Joan\\AppData\\Local\\Temp\\pycharm-packaging\\python-ldap\\

I'll appreciate all the help,

thank you in advance!

To correct the error due to dependencies to install the python-ldap

download the wheel file

http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap

python 3.6 is suitable with

python_ldap-3.2.0-cp36-cp36m-win_amd64.whl

Deploy the file in c:\\python36\\Scripts\\

install it with

python -m pip install python_ldap-3.2.0-cp36-cp36m-win_amd64.whl

It's because pip tries to compile OpenLDAP library and python-ldap is just a wrapper around binary lib. If you don't want to compile OpenLDAP library by yourself then I recommend this site: https://www.lfd.uci.edu/~gohlke/pythonlibs/

Download wheel-file you need, according to python version you use, for example python_ldap-3.2.0-cp37-cp37m-win_amd64.whl is for Python 3.6 64bit .

Then install:

python -m pip install python_ldap-3.2.0-cp37-cp37m-win_amd64.whl

对于 Windows,在尝试了许多选项后,在这种情况下对我有用的是:

    python -m pip install --only-binary :all: ldap

From the Python LDAP documentation you can see that it requires a series of packages in order to get a proper installation (pre-build requisites). The commands you need to run, depends on the OS.

Sadly, this is intended for Linux based OS's.

I hope it helps! Cheers

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