# Failed to import the required Python library (python-ldap)

**URL:** <https://forum.ansible.com/t/failed-to-import-the-required-python-library-python-ldap/32742>\
**Category:** Ansible Project\
**Created:** [April 21, 2020, 5:20am UTC](https://forum.ansible.com/t/failed-to-import-the-required-python-library-python-ldap/32742 "2020-04-21T05:20:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Javi\_Legido](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@Javi\_Legido](https://forum.ansible.com/u/Javi_Legido)\
**Post date:** [April 21, 2020, 5:20am UTC](https://forum.ansible.com/t/failed-to-import-the-required-python-library-python-ldap/32742/1 "2020-04-21T05:20:34Z")

</div>

Hi there.

First of all many thanks to all the people involved in this project for their time.

I’m facing an issue with ldap\_entry, details [here](https://github.com/ansible/ansible/issues/69045). Error message:

> Failed to import the required Python library (python-ldap) on remote\_host’s Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible\_python\_interpreter

Any help will be appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [April 21, 2020, 5:24am UTC](https://forum.ansible.com/t/failed-to-import-the-required-python-library-python-ldap/32742/2 "2020-04-21T05:24:26Z")

</div>

> Hi there.
> 
> First of all many thanks to all the people involved in this project for their time.
> 
> I'm facing an issue with ldap\_entry, details here \<[https://github.com/ansible/ansible/issues/69045&gt;\](https://github.com/ansible/ansible/issues/69045&gt;%5C). Error message:
> 
> &nbsp;&nbsp;&nbsp;&nbsp;Failed to import the required Python library (python-ldap) on remote\_host's Python /usr/bin/python3. Please read  
> &nbsp;&nbsp;&nbsp;&nbsp;module documentation and install in the appropriate location. If the required library is installed, but Ansible is  
> &nbsp;&nbsp;&nbsp;&nbsp;using the wrong Python interpreter, please consult the documentation on ansible\_python\_interpreter
> 
> Any help will be appreciated.
> 
> Thanks.

Hello Javi,

did you install the python3-ldap package on the target host?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Javi\_Legido](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@Javi\_Legido](https://forum.ansible.com/u/Javi_Legido)\
**Post date:** [April 21, 2020, 5:39am UTC](https://forum.ansible.com/t/failed-to-import-the-required-python-library-python-ldap/32742/3 "2020-04-21T05:39:41Z")

</div>

Good morning.

Shame on me, I installed by mistake ‘python-ldap’.

I would swear that I had installed ‘python3-ldap’…

Thanks a lot, that fixed my issue.

---

<div class="post-metadata">

**Author:** ![Chris\_Dev](https://avatars.discourse-cdn.com/v4/letter/c/aca169/32.png) [@Chris\_Dev](https://forum.ansible.com/u/Chris_Dev)\
**Post date:** [February 3, 2022, 11:21am UTC](https://forum.ansible.com/t/failed-to-import-the-required-python-library-python-ldap/32742/4 "2022-02-03T11:21:02Z")

</div>

Hello i have the same problem, if i want to start an inventory job (via Dashboard) i get this message:

"ansible-inventory 2.8.5  
config file = /etc/ansible/ansible.cfg  
configured module search path = [‘/var/lib/awx/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]

ansible python module location = /usr/lib/python3.6/site-packages/ansible

executable location = /usr/bin/ansible-inventory  
python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]  
Using /etc/ansible/ansible.cfg as config file  
setting up inventory plugins  
host\_list declined parsing /tmp/awx\_5739\_k\_o5anb8/tmpx75ji8ue as it did not pass it’s verify\_file() method  
auto declined parsing /tmp/awx\_5739\_k\_o5anb8/tmpx75ji8ue as it did not pass it’s verify\_file() method

toml declined parsing /tmp/awx\_5739\_k\_o5anb8/tmpx75ji8ue as it did not pass it’s verify\_file() method  
**[WARNING]: \* Failed to parse /tmp/awx\_5739\_k\_o5anb8/tmpx75ji8ue with script**

**plugin: Inventory script (/tmp/awx\_5739\_k\_o5anb8/tmpx75ji8ue) had an execution**  
**error: Traceback (most recent call last): File**

**“/tmp/awx\_5739\_k\_o5anb8/tmpx75ji8ue”, line 191, in raise**  
**AnsibleError(msg) ansible.errors.AnsibleError: Failed to import the required**  
**Python library (python-ldap) on awx’s Python**  
**/var/lib/awx/venv/ansible/bin/python. See [https://pypi.org/project/python-ldap/](https://pypi.org/project/python-ldap/)**  
**for more info. Please read module documentation and install in the appropriate**  
**location. Import Error: Traceback (most recent call last): File**  
**“/tmp/awx\_5739\_k\_o5anb8/tmpx75ji8ue”, line 172, in import ldap**  
**ModuleNotFoundError: No module named ‘ldap’"**

but if i try to install python-ldap i get:

[root@ansible site-packages]# pip install python3-ldap  
Requirement already satisfied: python3-ldap in /usr/local/lib/python3.6/site-packages (0.9.8.4)  
Requirement already satisfied: pyasn1\>=0.1.7 in /usr/lib/python3.6/site-packages (from python3-ldap) (0.4.7)  
WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: [https://pip.pypa.io/warnings/venv](https://pip.pypa.io/warnings/venv)  
[root@ansible site-packages]# pip install python-ldap  
Requirement already satisfied: python-ldap in /usr/lib64/python3.6/site-packages (3.1.0)  
Requirement already satisfied: pyasn1\>=0.3.7 in /usr/lib/python3.6/site-packages (from python-ldap) (0.4.7)  
Requirement already satisfied: pyasn1\_modules\>=0.1.5 in /usr/lib/python3.6/site-packages (from python-ldap) (0.2.7)  
WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: [https://pip.pypa.io/warnings/venv](https://pip.pypa.io/warnings/venv)

Some ideas or hints to solve this? The Ansible is in a Docker on a CentOS Maschine, if its necessary. Thank you
