Installing python-ldap for Ubuntu 18.04 in 2020 – Easy! – Python

If you ever come across the need to make any LDAP calls from a Python script you’ll probably need Python’s LDAP module. To do this you’ll need pip3 installed, to install it on Ubuntu you can check out this guide.

Next step is to install python-ldap and few system package prerequisites as pip3 doesn’t do this itself.

sudo apt-get install -y libsasl2-dev python3-dev libldap2-dev libssl-dev && pip3 install python-ldap --user

As a reminder, never try and fix pip issues with sudo. Pip should always be used in the user context.

 

After running the command and loading up the Python3 LDAP module:

python3 ldap ubuntu

Leave a Reply

You are currently viewing Installing python-ldap for Ubuntu 18.04 in 2020 – Easy! – Python