Unable to run 'expect' module

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:

`

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

Best Regards
Diptajeet

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

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

Best Regards
Diptajeet

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

Alright!

Best Regards
Diptajeet