# ansible & virtualenv

**URL:** <https://forum.ansible.com/t/ansible-virtualenv/12165>\
**Category:** Ansible Project\
**Created:** [December 26, 2012, 7:21pm UTC](https://forum.ansible.com/t/ansible-virtualenv/12165 "2012-12-26T19:21:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Martin](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@James\_Martin](https://forum.ansible.com/u/James_Martin)\
**Post date:** [December 26, 2012, 7:21pm UTC](https://forum.ansible.com/t/ansible-virtualenv/12165/1 "2012-12-26T19:21:48Z")

</div>

I’m using a custom module that calls out to boto, but when I run the  
module, it get the following error:

failed: [localhost] =\> {“failed”: true, “parsed”: false}  
invalid output was: Traceback (most recent call last):  
File “/Users/jmartin/.ansible/tmp/  
ansible-1356307230.15-113161473433942/botoec2”,  
line 99, in   
import boto.ec2  
ImportError: No module named boto.ec2

I’m sure that boto is installed in my virtualenv, as is ansible:

(ansible)Jamess-MacBook-Air:ansible-riak jmartin$ lssitepackages |grep  
-E ‘boto|ansible’  
ansible  
ansible-0.9-py2.7.egg-info  
boto  
boto-2.6.0-py2.7.egg-info

My question is, how can I get ansible to honor my virtualenv when  
executing a custom module that runs locally?

Thanks,

James

---

<div class="post-metadata">

**Author:** ![Daniel\_Hokka\_Zakriss](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@Daniel\_Hokka\_Zakriss](https://forum.ansible.com/u/Daniel_Hokka_Zakriss)\
**Post date:** [December 28, 2012, 3:12pm UTC](https://forum.ansible.com/t/ansible-virtualenv/12165/2 "2012-12-28T15:12:32Z")

</div>

James Martin wrote:

> I'm using a custom module that calls out to boto, but when I run the  
> module, it get the following error:
> 
> failed: [localhost] =\> {"failed": true, "parsed": false}  
> invalid output was: Traceback (most recent call last):  
> &nbsp;&nbsp;File "/Users/jmartin/.ansible/tmp/  
> ansible-1356307230.15-113161473433942/botoec2",  
> line 99, in \<module\>  
> &nbsp;&nbsp;&nbsp;&nbsp;import boto.ec2  
> ImportError: No module named boto.ec2
> 
> I'm sure that boto is installed in my virtualenv, as is ansible:
> 
> (ansible)Jamess-MacBook-Air:ansible-riak jmartin$ lssitepackages |grep  
> -E 'boto|ansible'  
> ansible  
> ansible-0.9-py2.7.egg-info  
> boto  
> boto-2.6.0-py2.7.egg-info
> 
> My question is, how can I get ansible to honor my virtualenv when  
> executing a custom module that runs locally?

Set a host variable for 127.0.0.1 of ansible\_python\_interpreter to your  
virtualenv's Python interpreter.

Daniel
