我正在尝试使用PyCharm安装python-ldap软件包,但无法解决问题,出现以下错误:
错误消息:
收集python-ldap 使用缓存的https://files.pythonhosted.org/packages/7f/1c/28d721dff2fcd2fef9d55b40df63a00be26ec8a11e8c6fc612ae642f9cfd/python-ldap-3.1.0.tar.gz 收集pyasn1> = 0.3.7(来自python-ldap) 使用缓存的https://files.pythonhosted.org/packages/a0/70/2c27740f08e477499ce19eefe05dbcae6f19fdc49e9e82ce4768be0643b9/pyasn1-0.4.3-py2.py3-none-any.whl 收集pyasn1_modules> = 0.1.5(来自python-ldap) 使用缓存的https://files.pythonhosted.org/packages/e9/51/bcd96bf6231d4b2cc5e023c511bee86637ba375c44a6f9d1b4b7ad1ce4b9/pyasn1_modules-0.2.1-py2.py3-none-any.whl 安装收集的软件包:pyasn1,pyasn1-modules,python-ldap 运行python-ldap的setup.py install:已启动 为python-ldap运行setup.py install:状态为“错误” 从命令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-单个版本-外部管理-编译--install-headers C:\ Users \ Joan \ PycharmProjects \ prueba \ venv \ include \ site \ python3.6 \ python-ldap: 运行安装 运行构建 运行build_py 创建build \ lib.win-amd64-3.6 复制Lib \ ldapurl.py-> build \ lib.win-amd64-3.6 复制Lib \ ldif.py-> build \ lib.win-amd64-3.6 创建build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ async.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ asyncsearch.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ cidict.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ compat.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ constants.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ dn.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ filter.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ functions.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ ldapobject.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ logger.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ modlist.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ pkginfo.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ resiter.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ sasl.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap \ syncrepl.py-> build \ lib.win-amd64-3.6 \ ldap 复制Lib \ ldap__init __。py-> build \ lib.win-amd64-3.6 \ ldap 创建build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ deref.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ libldap.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ openldap.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ pagedresults.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ ppolicy.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ psearch.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ pwdpolicy.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ readentry.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ sessiontrack.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ simple.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ sss.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls \ vlv.py-> build \ lib.win-amd64-3.6 \ ldap \ controls 复制Lib \ ldap \ controls__init __。py-> build \ lib.win-amd64-3.6 \ ldap \ controls 创建build \ lib.win-amd64-3.6 \ ldap \ extop 复制Lib \ ldap \ extop \ dds.py-> build \ lib.win-amd64-3.6 \ ldap \ extop 复制Lib \ ldap \ extop__init __。py-> build \ lib.win-amd64-3.6 \ ldap \ extop 创建build \ lib.win-amd64-3.6 \ ldap \ schema 复制Lib \ ldap \ schema \ models.py-> build \ lib.win-amd64-3.6 \ ldap \ schema 复制Lib \ ldap \ schema \ subentry.py-> build \ lib.win-amd64-3.6 \ ldap \ schema 复制Lib \ ldap \ schema \ tokenizer.py-> build \ lib.win-amd64-3.6 \ ldap \ schema 复制Lib \ ldap \ schema__init __。py-> build \ lib.win-amd64-3.6 \ ldap \ schema 创建build \ lib.win-amd64-3.6 \ slapdtest 复制Lib \ slapdtest_slapdtest.py-> build \ lib.win-amd64-3.6 \ slapdtest 复制Lib \ slapdtest__init __。py-> build \ lib.win-amd64-3.6 \ slapdtest 运行egg_info 编写Lib \ python_ldap.egg-info \ PKG-INFO 将dependency_links写入Lib \ python_ldap.egg-info \ dependency_links.txt 将要求写入Lib \ python_ldap.egg-info \ requires.txt 将顶级名称写入Lib \ python_ldap.egg-info \ top_level.txt 读取清单文件“ Lib \ python_ldap.egg-info \ SOURCES.txt” 阅读清单模板“ MANIFEST.in” 找不到与“ Doc.build”匹配的先前包含的目录 编写清单文件“ Lib \ python_ldap.egg-info \ SOURCES.txt” 创建build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ README-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ ca.conf-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ ca.pem-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ client.conf-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ client.key-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ client.pem-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ gencerts.sh-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ gennssdb.sh-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ server.conf-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ server.key-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 复制Lib \ slapdtest \ certs \ server.pem-> build \ lib.win-amd64-3.6 \ slapdtest \ certs 警告:build_py:禁用字节编译,正在跳过。
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
----------------------------------------
命令“ C:\ Users \ Joan \ PycharmProjects \ prueba \ venv \ Scripts \ python.exe -u -c”导入设置工具,标记化; 文件 ='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-单个版本-外部管理-编译--install-headers C:\ Users \ Joan \ PycharmProjects \ prueba \ venv \ include \ site \ python3.6 \ python-ldap“在C:\ Users \ Joan \ AppData \ Local \ Temp \ pycharm-packaging \ python-ldap \
中失败,错误代码为1感谢您的帮助,
提前谢谢!
答案 0 :(得分:1)
对于Windows,在尝试了许多选择之后,在这种情况下对我有用的是:
python -m pip install --only-binary :all: ldap
答案 1 :(得分:0)
这是因为pip尝试编译OpenLDAP库,而python-ldap只是二进制lib的包装。如果您不想自己编译OpenLDAP库,则建议您访问以下站点: https://www.lfd.uci.edu/~gohlke/pythonlibs/
根据您使用的python版本下载所需的wheel-file,例如 python_ldap-3.2.0-cp37-cp37m-win_amd64.whl 用于 Python 3.6 64bit >。
然后安装:
python -m pip install python_ldap-3.2.0-cp37-cp37m-win_amd64.whl
答案 2 :(得分:0)
要纠正由于安装python-ldap的依赖性而导致的错误
下载whl文件
http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap.
带有
的python 3.6套装python_ldap-3.2.0-cp36-cp36m-win_amd64.whl
将文件部署到c:\python36\Scripts\
通过
安装python -m pip install python_ldap-3.2.0-cp36-cp36m-win_amd64.whl
答案 3 :(得分:0)
从Python LDAP documentation中您可以看到它需要一系列软件包才能正确安装(预构建要求)。您需要运行的命令取决于操作系统。
遗憾的是,这是针对基于Linux的操作系统的。
希望对您有所帮助!干杯