1

I've been trying to install python-ldap for a good while now. I've tried both these commands:

pip3 install python-ldap
pip install python-ldap

And I get the same error after installing Microsoft Build tools (I am on windows 11).

I'm not too sure why this is happening. I've installed 2022 Microsoft Build Tools and I am on Python version 3.9.13 and I am using Pycharm as the IDE in this case.

I’ve also tried restarting my computer several times

Collecting python-ldap
  Using cached python-ldap-3.4.3.tar.gz (377 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting pyasn1-modules>=0.1.5
  Using cached pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB)
Collecting pyasn1>=0.3.7
  Using cached pyasn1-0.5.0-py2.py3-none-any.whl (83 kB)
Building wheels for collected packages: python-ldap
  Building wheel for python-ldap (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for python-ldap (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [94 lines of output]
      C:\Users\liudani1\AppData\Local\Temp\pip-build-env-1xy93uhp\overlay\Lib\site-packages\setuptools\config\setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
      !!

              ********************************************************************************
              The license_file parameter is deprecated, use license_files instead.

              By 2023-Oct-30, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************

      !!
        parsed = self.parsers.get(option_name, lambda x: x)(value)
      running bdist_wheel
      running build
      running build_py
      creating build\lib.win-amd64-cpython-39
      copying Lib\ldapurl.py -> build\lib.win-amd64-cpython-39
      copying Lib\ldif.py -> build\lib.win-amd64-cpython-39
      creating build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\async.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\asyncsearch.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\cidict.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\compat.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\constants.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\dn.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\filter.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\functions.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\ldapobject.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\logger.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\modlist.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\pkginfo.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\resiter.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\sasl.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\syncrepl.py -> build\lib.win-amd64-cpython-39\ldap
      copying Lib\ldap\__init__.py -> build\lib.win-amd64-cpython-39\ldap
      creating build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\deref.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\libldap.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\openldap.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\pagedresults.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\ppolicy.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\psearch.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\pwdpolicy.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\readentry.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\sessiontrack.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\simple.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\sss.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\vlv.py -> build\lib.win-amd64-cpython-39\ldap\controls
      copying Lib\ldap\controls\__init__.py -> build\lib.win-amd64-cpython-39\ldap\controls
      creating build\lib.win-amd64-cpython-39\ldap\extop
      copying Lib\ldap\extop\dds.py -> build\lib.win-amd64-cpython-39\ldap\extop
      copying Lib\ldap\extop\passwd.py -> build\lib.win-amd64-cpython-39\ldap\extop
      copying Lib\ldap\extop\__init__.py -> build\lib.win-amd64-cpython-39\ldap\extop
      creating build\lib.win-amd64-cpython-39\ldap\schema
      copying Lib\ldap\schema\models.py -> build\lib.win-amd64-cpython-39\ldap\schema
      copying Lib\ldap\schema\subentry.py -> build\lib.win-amd64-cpython-39\ldap\schema
      copying Lib\ldap\schema\tokenizer.py -> build\lib.win-amd64-cpython-39\ldap\schema
      copying Lib\ldap\schema\__init__.py -> build\lib.win-amd64-cpython-39\ldap\schema
      creating build\lib.win-amd64-cpython-39\slapdtest
      copying Lib\slapdtest\_slapdtest.py -> build\lib.win-amd64-cpython-39\slapdtest
      copying Lib\slapdtest\__init__.py -> build\lib.win-amd64-cpython-39\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'
      adding license file 'LICENCE'
      writing manifest file 'Lib\python_ldap.egg-info\SOURCES.txt'
      creating build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\README -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\ca.conf -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\ca.pem -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\client.conf -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\client.key -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\client.pem -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\gencerts.sh -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\gennssdb.sh -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\server.conf -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\server.key -> build\lib.win-amd64-cpython-39\slapdtest\certs
      copying Lib\slapdtest\certs\server.pem -> build\lib.win-amd64-cpython-39\slapdtest\certs
      running build_ext
      building '_ldap' extension
      creating build\temp.win-amd64-cpython-39
      creating build\temp.win-amd64-cpython-39\Release
      creating build\temp.win-amd64-cpython-39\Release\Modules
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=3.4.3 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -IC:\dan_liu\depot
\ttc\csi\csi3\modules\venv\include -IC:\Users\liudani1\AppData\Local\Programs\Python\Python39\include -IC:\Users\liudani1\AppData\Local\Programs\Python\Python39\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\include" "-IC:\Program Files (x86)\Microsoft Visual
 Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" /TcModules/LDAPObject.c /Fobuild\temp.win-amd64-cpython-39\Release\Modules/LDAPObject.obj
      LDAPObject.c
      C:\Users\liudani1\AppData\Local\Temp\pip-install-cg201zrl\python-ldap_d40a9a201a004a818a4d6c435bdea61c\Modules\common.h(15): fatal error C1083: Cannot open include file: 'lber.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.36.32532\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for python-ldap
Failed to build python-ldap
ERROR: Could not build wheels for python-ldap, which is required to install pyproject.toml-based projects
danielliucs
  • 61
  • 2
  • 6
  • Check this answer on how to install libraries from PyCharm: https://stackoverflow.com/a/66016514/9714255. – LoukasPap May 24 '23 at 21:28
  • Oh I should have mentioned. I have also tried that! It’s the same error as if I try it through terminal – danielliucs May 24 '23 at 23:12
  • Check this answer: https://stackoverflow.com/questions/75736939/error-could-not-build-wheels-for-python-ldap-which-is-required-to-install-pypr – LoukasPap May 25 '23 at 08:08
  • I think that is for linux? I'm on windows. I have gcc installed though and the python-dev stuff – danielliucs May 26 '23 at 15:45
  • There are many possible answers in the web. Have you searched them? Here is another one: https://stackoverflow.com/questions/75736939/error-could-not-build-wheels-for-python-ldap-which-is-required-to-install-pypr – LoukasPap May 26 '23 at 21:20
  • On windows you will have to install python-ldap using a python wheel. Follow these [steps](https://stackoverflow.com/a/58235938/2529954). – EricLavault May 27 '23 at 12:25
  • Hi @EricLavault So I tried that link but it seems like that link is no longer supported. Is there an alternative to that instead? – danielliucs May 29 '23 at 13:02
  • 1
    I was referring to the answer from @Nickolay with 27 upvotes which is more detailed than the accepted answer, and for which I precisely updated the link. – EricLavault May 29 '23 at 14:00

0 Answers0