# Ansible not recognizing correct pexpect module?

**URL:** <https://forum.ansible.com/t/ansible-not-recognizing-correct-pexpect-module/27523>\
**Category:** Ansible Project\
**Created:** [May 14, 2018, 3:35pm UTC](https://forum.ansible.com/t/ansible-not-recognizing-correct-pexpect-module/27523 "2018-05-14T15:35:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [May 14, 2018, 3:35pm UTC](https://forum.ansible.com/t/ansible-not-recognizing-correct-pexpect-module/27523/1 "2018-05-14T15:35:43Z")

</div>

`

$ ansible --version  
ansible 2.4.0.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/home/scscm\_builder/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/local/lib/python2.7/site-packages/ansible-2.4.0.0-py2.7.egg/ansible  
executable location = /usr/local/bin/ansible  
python version = 2.7.14 (default, Nov 10 2017, 18:14:45) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]

`

I’m trying to make the “expect” module in ansible, and I get

`

fatal: [localhost]: FAILED! =\> {“changed”: false, “failed”: true, “msg”: “Insufficient version of pexpect installed (2.3), this module requires pexpect\>=3.3. Error was ‘module’ object has no attribute ‘runu’”}

`

But pip tells me I already pexpect version 4.5.0?

`

$ pip2.7 install --upgrade pexpect  
Requirement already up-to-date: pexpect in /usr/local/lib/python2.7/site-packages (4.5.0)  
Requirement not upgraded as not directly required: ptyprocess\>=0.5 in /usr/local/lib/python2.7/site-packages (from pexpect) (0.5.2)

`

What am I missing?

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [May 14, 2018, 4:02pm UTC](https://forum.ansible.com/t/ansible-not-recognizing-correct-pexpect-module/27523/2 "2018-05-14T16:02:01Z")

</div>

I meant to say “I’m trying to use the “expect” module in ansible…”

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 14, 2018, 4:11pm UTC](https://forum.ansible.com/t/ansible-not-recognizing-correct-pexpect-module/27523/3 "2018-05-14T16:11:22Z")

</div>

It requires it on the machine and python the module executes on, use  
-vvv to verify you are matching both, by default the implicit  
localhost should ensure that they are the same as you expect, but if  
you added localhost to your inventory you might be using a different  
python [http://docs.ansible.com/ansible/latest/inventory/implicit\_localhost.html](http://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html)

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [May 14, 2018, 4:33pm UTC](https://forum.ansible.com/t/ansible-not-recognizing-correct-pexpect-module/27523/4 "2018-05-14T16:33:19Z")

</div>

Thanks Brian. I should’ve indicated that I’m running this on localhost

`$ ansible-playbook -i "localhost," test-expect.yml`

I added the

`  
ansible\_python\_interpreter: python2.7

`

in my playbook and it worked for now. For some reason, this “{{ ansible\_playbook\_python }}” didn’t work for me, but I’ll debug that next.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 14, 2018, 4:42pm UTC](https://forum.ansible.com/t/ansible-not-recognizing-correct-pexpect-module/27523/5 "2018-05-14T16:42:23Z")

</div>

The -i 'localhost,' is probably what is causing the issue as you are  
defining localhost, see the docs i linked in previous message for a  
full explanation.
