# Now using /usr/bin/env python vs /usr/bin/python to work better with virtualenv, etc

**URL:** <https://forum.ansible.com/t/now-using-usr-bin-env-python-vs-usr-bin-python-to-work-better-with-virtualenv-etc/11375>\
**Category:** Ansible Project\
**Created:** [March 27, 2012, 2:27am UTC](https://forum.ansible.com/t/now-using-usr-bin-env-python-vs-usr-bin-python-to-work-better-with-virtualenv-etc/11375 "2012-03-27T02:27:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [March 27, 2012, 2:27am UTC](https://forum.ansible.com/t/now-using-usr-bin-env-python-vs-usr-bin-python-to-work-better-with-virtualenv-etc/11375/1 "2012-03-27T02:27:58Z")

</div>

I received quite a few requests for this.

For those looking, it’s in place now in the latest git source.

–Michael

---

<div class="post-metadata">

**Author:** ![Carl\_Wolff](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Carl\_Wolff](https://forum.ansible.com/u/Carl_Wolff)\
**Post date:** [September 7, 2012, 11:32am UTC](https://forum.ansible.com/t/now-using-usr-bin-env-python-vs-usr-bin-python-to-work-better-with-virtualenv-etc/11375/2 "2012-09-07T11:32:16Z")

</div>

Would it be possible to define the python binary in a playbook?  
“env python” is perfect as long as the binary is named “python”.  
However, during my test on a mips-host (Tomato router), i got an error since the binary is named python2.6

It would be super if this could be configured easily…

---

<div class="post-metadata">

**Author:** ![Carl\_Wolff](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@Carl\_Wolff](https://forum.ansible.com/u/Carl_Wolff)\
**Post date:** [September 7, 2012, 11:33am UTC](https://forum.ansible.com/t/now-using-usr-bin-env-python-vs-usr-bin-python-to-work-better-with-virtualenv-etc/11375/3 "2012-09-07T11:33:18Z")

</div>

I add the result Daniel Hozac gave me: use ansible\_python\_interpreter

---

<div class="post-metadata">

**Author:** ![jpmens1](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@jpmens1](https://forum.ansible.com/u/jpmens1)\
**Post date:** [September 7, 2012, 11:38am UTC](https://forum.ansible.com/t/now-using-usr-bin-env-python-vs-usr-bin-python-to-work-better-with-virtualenv-etc/11375/4 "2012-09-07T11:38:35Z")

</div>

> Would it be possible to define the python binary in a playbook?  
> "env python" is perfect as long as the binary is named "python".  
> However, during my test on a mips-host (Tomato router), i got an error  
> since the binary is named python2.6
> 
> It would be super if this could be configured easily...

For example, in your inventory file:

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$ cat hosts  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;your.tomato.router ansible\_python\_interpreter=/some/path/python2.6/bin/python

I learned that recently and it's saved my bacon 😉

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP
