You are reading documentation for an unreleased version.
Following these instructions will currently get you version 2.5.2, which does not support Python 3.
Installing from PyPI¶
python -m pip install python-ldap
For installing from PyPI, you will need the same Build prerequisites as when installing from source.
We do not currently provide pre-built packages (wheels).
Because distributions seem to be all over the place, this page tries to list all the current ones we know of.
Note that the python-ldap team is not responsible for the binary packages except the sources you can grab from the PyPI page. Also note that binary packages are most times not up to date. If you experience troubles with a binary package, it would be nice if you try to build a recent version of python-ldap before submitting a bug report to make sure you did not hit a problem already fixed in recent releases.
Have a look into the Debian Package Tracker to get up to date information which versions are available.
Mac OS X¶
You can install directly with pip:
xcode-select --install pip install python-ldap \ --global-option=build_ext \ --global-option="-I$(xcrun --show-sdk-path)/usr/include/sasl"
Installing from Source¶
python-ldap is built and installed using the Python setuptools. From a source repository:
python -m pip install setuptools python setup.py install
If you have more than one Python interpreter installed locally, you should use the same one you plan to use python-ldap with.
Further instructions can be found in Setuptools documentation.
The following software packages are required to be installed on the local system when building python-ldap:
- Python version 2.7, or 3.3 or later including its development files
- C compiler corresponding to your Python version (on Linux, it is usually
- OpenLDAP client libs version 2.4.11 or later; it is not possible and not supported to build with prior versions.
- OpenSSL (optional)
- Cyrus SASL (optional)
- Kerberos libraries, MIT or Heimdal (optional)
The file setup.cfg allows to set some build and installation
parameters for reflecting the local installation of required
software packages. Only section
[_ldap] is described here.
More information about other sections can be found in
Specifies in which directories to search for required libraries.
Specifies in which directories to search for include files of required libraries.
The LDAP protocol library of OpenLDAP.
ldap_ris the reentrant version and should be preferred.
The BER encoder/decoder library of OpenLDAP.
The Cyrus-SASL library (optional)
The SSL/TLS library of OpenSSL (optional)
The basic cryptographic library of OpenSSL (optional)
The following example is for a full-featured build (including SSL and SASL support)
of python-ldap with OpenLDAP installed in a different prefix directory
/opt/openldap-2.4) and SASL header files found in /usr/include/sasl.
Debugging symbols are preserved with compile option
[_ldap] library_dirs = /opt/openldap-2.4/lib include_dirs = /opt/openldap-2.4/include /usr/include/sasl extra_compile_args = -g extra_objects = libs = ldap_r lber sasl2 ssl crypto