# Failed to import the required Python library (pexpect) - Ansible

**URL:** <https://forum.ansible.com/t/failed-to-import-the-required-python-library-pexpect-ansible/33044>\
**Category:** Ansible Developer\
**Created:** [May 28, 2020, 8:01pm UTC](https://forum.ansible.com/t/failed-to-import-the-required-python-library-pexpect-ansible/33044 "2020-05-28T20:01:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carina\_Muller](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@Carina\_Muller](https://forum.ansible.com/u/Carina_Muller)\
**Post date:** [May 28, 2020, 8:01pm UTC](https://forum.ansible.com/t/failed-to-import-the-required-python-library-pexpect-ansible/33044/1 "2020-05-28T20:01:08Z")

</div>

In my `ansible playbook` I am using `expect` module.  
The error that I get is:

“msg”: “Failed to import the required Python library (pexpect) on quickstart.cloudera’s Python /usr/bin/python. 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”

I have python3 and pexpect on the quickstart.cloudera docker installed and ansible is using python3:

[root@quickstart Python-3.6.3]# ansible --version  
ansible 2.9.9  
config file = None  
configured module search path = [‘/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible  
executable location = /usr/local/bin/ansible  
python version = 3.6.3 (default, May 28 2020, 16:56:01) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]

[root@quickstart Python-3.6.3]# python --version  
Python 3.6.3

I have also installed pexpect, but when I want to see the version:

[root@quickstart Python-3.6.3]# pexpect --version  
-bash: pexpect: command not found

[root@quickstart Python-3.6.3]# pip3.6 install pexpect  
Requirement already satisfied: pexpect in /usr/local/lib/python3.6/site-packages  
Requirement already satisfied: ptyprocess\>=0.5 in /usr/local/lib/python3.6/site-packages (from pexpect)  
You are using pip version 9.0.1, however version 20.1.1 is available.  
You should consider upgrading via the ‘pip install --upgrade pip’ command.

Does anyone see the problem and can help me?
