# More local\_action and ansible\_python\_interpreters

**URL:** <https://forum.ansible.com/t/more-local-action-and-ansible-python-interpreters/12765>\
**Category:** Ansible Project\
**Created:** [May 3, 2013, 2:51am UTC](https://forum.ansible.com/t/more-local-action-and-ansible-python-interpreters/12765 "2013-05-03T02:51:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timothy\_Appnel](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@Timothy\_Appnel](https://forum.ansible.com/u/Timothy_Appnel)\
**Post date:** [May 3, 2013, 2:51am UTC](https://forum.ansible.com/t/more-local-action-and-ansible-python-interpreters/12765/1 "2013-05-03T02:51:13Z")

</div>

I hit a snag that occupied me for a good part of the day with how Ansible handles local actions and alternate paths to python interpreters. I saw that there has been some discussion over the months[1,2], but the resolution, if any, is unclear to me.

All of our servers are running a version of Red Hat that only ships with Python 2.4. A more modern Python (2.7) is in at an alternate location. When I tried to get a playbook using a local\_action in the pre\_task section I got a json could not be imported error. Even though I’ve created a localhost and 127.0.0.1 entry with a anisible\_python\_interpreter variable pointing to python 2.7, it still calls the default /usr/bin/python and that is 2.4. Since local\_actions uses sh the environment variable settings (like PYTHONPATH) that I setup to get my python environment to where I need it are not passed along. So I understand why I’m getting this error. I don’t understand how to work around it.

How have other users been dealing with this? Any suggestions would be appreciated.

BTW: I’m running a version I pulled from github a few days ago. Installing simplejson for Python 2.4 in the default library path is not an option. (It’s out of my control otherwise the issue would have been solved already.)

[1] [https://github.com/ansible/ansible/issues/1019](https://github.com/ansible/ansible/issues/1019)  
[2] [https://github.com/ansible/ansible/issues/1225](https://github.com/ansible/ansible/issues/1225)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [May 3, 2013, 2:55am UTC](https://forum.ansible.com/t/more-local-action-and-ansible-python-interpreters/12765/2 "2013-05-03T02:55:03Z")

</div>

So yes, this really should look up something that resembles localhost in inventory and see if it has any ansible\_python\_interpreter variables set.

I was trying to force the “Little Red Hen” scenario earlier by getting someone using it to submit a patch, somewhat unsuccessfully, as it wasn’t something I needed.

I believe the SSH port one is different than the ansible\_python\_interpreter one.

Patches would still be accepted.

---

<div class="post-metadata">

**Author:** ![Timothy\_Appnel](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@Timothy\_Appnel](https://forum.ansible.com/u/Timothy_Appnel)\
**Post date:** [May 3, 2013, 3:06am UTC](https://forum.ansible.com/t/more-local-action-and-ansible-python-interpreters/12765/3 "2013-05-03T03:06:35Z")

</div>

I guess I’ll have to take a look at it when I get in tomorrow to see what I can do.
