# run expect task in virtualenv, and not other tasks

**URL:** <https://forum.ansible.com/t/run-expect-task-in-virtualenv-and-not-other-tasks/25234>\
**Category:** Ansible Project\
**Created:** [August 11, 2017, 3:28pm UTC](https://forum.ansible.com/t/run-expect-task-in-virtualenv-and-not-other-tasks/25234 "2017-08-11T15:28:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Lofgren](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@John\_Lofgren](https://forum.ansible.com/u/John_Lofgren)\
**Post date:** [August 11, 2017, 3:28pm UTC](https://forum.ansible.com/t/run-expect-task-in-virtualenv-and-not-other-tasks/25234/1 "2017-08-11T15:28:38Z")

</div>

I’m having trouble figuring out how I can run a task with ‘expect’ module in a virtualenv and not have my other tasks run in that virtualenv.

The only way I’ve found to run an expect task in a virtualenv is to set\_fact ansible\_python\_interpreter, but once I’ve done that, I cannot unset it, so all python-related tasks that run after that also run in the same virtualenv. Is there some way to set the python interpreter for only a single expect task?

I use pew ([https://github.com/berdario/pew](https://github.com/berdario/pew)) for managing virtualenvs, but that is likely not relevant.

Thanks,  
John
