# Unable to run 'expect' module

**URL:** <https://forum.ansible.com/t/unable-to-run-expect-module/29630>\
**Category:** Ansible Project\
**Created:** [February 6, 2019, 12:51pm UTC](https://forum.ansible.com/t/unable-to-run-expect-module/29630 "2019-02-06T12:51:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alain\_Desilets](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@Alain\_Desilets](https://forum.ansible.com/u/Alain_Desilets)\
**Post date:** [February 6, 2019, 12:51pm UTC](https://forum.ansible.com/t/unable-to-run-expect-module/29630/1 "2019-02-06T12:51:39Z")

</div>

I am trying to run a playbook (see end of the post), which invokes the ‘expect’ module.

But when I run it, I get error:

`

TASK [Run anaconda installation script] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

fatal: [127.0.0.1]: FAILED! =\> {“changed”: false, “msg”: “The pexpect python module is required”}

`

Yet, the ‘pip’ task that is supposed to install pexpect runs without error.

What am I doing wrong?

Thx.

Alain Désilets

Content of the playbook:

`

---

<div class="post-metadata">

**Author:** ![Diptajeet\_Khan](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@Diptajeet\_Khan](https://forum.ansible.com/u/Diptajeet_Khan)\
**Post date:** [February 6, 2019, 1:22pm UTC](https://forum.ansible.com/t/unable-to-run-expect-module/29630/2 "2019-02-06T13:22:32Z")

</div>

Install “expect” using “yum” rather than “pexpect” using “pip”.

Best Regards  
Diptajeet

---

<div class="post-metadata">

**Author:** ![Alain\_Desilets](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@Alain\_Desilets](https://forum.ansible.com/u/Alain_Desilets)\
**Post date:** [February 6, 2019, 2:23pm UTC](https://forum.ansible.com/t/unable-to-run-expect-module/29630/3 "2019-02-06T14:23:25Z")

</div>

Thx Diptajeet,

I am on OSX, so I can’t install with yum. I did however install ‘expect’ using homebrew as follows:

brew install expect

This installed v5.45.4 of expect. Yet, I still get the pexpect error message.

Alain

---

<div class="post-metadata">

**Author:** ![Diptajeet\_Khan](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@Diptajeet\_Khan](https://forum.ansible.com/u/Diptajeet_Khan)\
**Post date:** [February 6, 2019, 2:29pm UTC](https://forum.ansible.com/t/unable-to-run-expect-module/29630/4 "2019-02-06T14:29:37Z")

</div>

I see. Can you also try “brew install pexpect” and run the Ansible code.

Best Regards  
Diptajeet

---

<div class="post-metadata">

**Author:** ![Alain\_Desilets](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@Alain\_Desilets](https://forum.ansible.com/u/Alain_Desilets)\
**Post date:** [February 6, 2019, 3:23pm UTC](https://forum.ansible.com/t/unable-to-run-expect-module/29630/5 "2019-02-06T15:23:32Z")

</div>

Found it! By default, Ansible uses a particular path for finding the Python interpreter it uses to run the playbooks. This turned out to be different from the interpreter on which I had isntalled pexpect.

I fixed the issue by passing the following argument to my ansible-playbook command:

-e 'ansible\_python\_interpreter=/path/to/my/python

Alain

---

<div class="post-metadata">

**Author:** ![Diptajeet\_Khan](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@Diptajeet\_Khan](https://forum.ansible.com/u/Diptajeet_Khan)\
**Post date:** [February 6, 2019, 3:58pm UTC](https://forum.ansible.com/t/unable-to-run-expect-module/29630/6 "2019-02-06T15:58:40Z")

</div>

Alright!

Best Regards  
Diptajeet
