# Python Annoying error when connecting to target machines

**URL:** <https://forum.ansible.com/t/python-annoying-error-when-connecting-to-target-machines/24381>\
**Category:** Ansible Project\
**Created:** [May 2, 2017, 5:24pm UTC](https://forum.ansible.com/t/python-annoying-error-when-connecting-to-target-machines/24381 "2017-05-02T17:24:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Youssef](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Anthony\_Youssef](https://forum.ansible.com/u/Anthony_Youssef)\
**Post date:** [May 2, 2017, 5:24pm UTC](https://forum.ansible.com/t/python-annoying-error-when-connecting-to-target-machines/24381/1 "2017-05-02T17:24:54Z")

</div>

Hi,

i am facing an error that is blocking my work on ansible. i am trying to connect from my control machine to a big number of hosts to execute remote commands (around 1000 hosts).

some of these target hosts didn’t have python2.6 installed under /usr/bin/python, thus i was not able to connect to them.

Unix team suggested to put python2.6 under a shared location and thus all machines will be able to connect to it(shared location=./nettools/python\_ansible/bin/python), i updated my “group\_vars/all” to point to this location, as per below

ansible\_python\_interpreter: /nettools/python\_ansible/bin/python

now when trying to connect to remote hosts, i faced many issues related to libraries

```auto

hp214srv | FAILED! => {
 "changed": false,
 "failed": true,
 "module_stderr": "ld.so.1: python: fatal: libpython2.6.so.1.0: open failed: No such file or directory\n/bin/bash: line 1: 3469 Killed /nettools/python_ansible/bin/python\n",
 "module_stdout": "",
 "msg": "MODULE FAILURE"
}

1. 

```

only machines having python2.6 installed locally were still able to connect since libpython2.6.so.1.0 was found locally (i knew this after running ldd on the python executable)

what i did next, is that i created a wrapper /nettools/python\_ansible/bin/python.sh and below is the code inside the wrapper

```auto

hp225srv autoengine /usr/local/quality/test/bin/
bash$ vi python.sh
"python.sh" 6 lines, 1088 characters
#!/bin/bash
export PATH="/nettools/subversion/bin:/nettools/python/bin:/nettools/cmake/cmake-2.6.1/bin:/nettools/sudo/sudo1.7.2p1/bin:/usr/local/java/jdk1.7.0_79/bin:.:/usr/local/bin:/usr/bin:/bin:/nfshome/nonuser/autoengine/bin:/usr/sfw/bin:/usr
/local/tex/bin/:/etc:/usr/etc:/usr/openwin/bin:/usr/ccs/bin:/opt/csw/bin:/opt/HPQhealth/sbin/:/opt/HPQacucli/sbin/:/sbin:/usr/sbin:/usr/local/tools:/nettools/tools:/nettools/sunstudio/sunstudio11/SUNWspro/bin:/opt/oracle/11204/bin:/op
t/sybase/oc12.5.1-EBF12837/OCS-12_5/bin:/nettools/bin:/nfs_tools/common/scripts:/nfs_tools/common/operate:/nfs_tools/common/globalqa:/usr/ucb:/opt/sfw/bin:/usr/sbin:/nettools/python_ansible/bin"
export LD_LIBRARY_PATH="/usr/local/lib:/usr/local/ssl/lib:/opt/sfw/lib:/usr/lib:/nettools/sunstudio/sunstudio11/SUNWspro/lib:/opt/oracle/11204/lib:/nettools/sudo/sudo1.7.2p1/lib:/nettools/cmake/cmake-2.6.1/share/cmake-2.6/Lib:/nettool
s/python/lib:/nettools/lib:/usr/ucblib:/nettools/subversion/lib:/nettools/python_ansible/lib"
export PYTHONHOME="/nettools/python_ansible"
echo "ayoussef"
exec /nettools/python/bin/python "$@"

1. 

```

this time where running `ansible -m ping dell190srv,dell201srv,dell027srv,hp214srv,hp244srv` from control machine i got the below output

```auto

hp244srv | FAILED! => {
 "changed": false,
 "failed": true,
 "module_stderr": "Could not find platform independent libraries <prefix>\nCould not find platform dependent libraries <exec_prefix>\nConsider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n'import site' failed; use -v for traceback\nTraceback (most recent call last):\n File \"<stdin>\", line 4, in <module>\nImportError: No module named os\n",
 "module_stdout": "",
 "msg": "MODULE FAILURE"
}
hp214srv | FAILED! => {
 "changed": false,
 "failed": true,
 "module_stderr": "ld.so.1: python: fatal: relocation error: file /nettools/python_ansible/lib/libpython2.6.so.1.0: symbol fdatasync: referenced symbol not found\n/bin/bash: line 1: 5699 Killed /nettools/python_ansible/bin/python.sh\n",
 "module_stdout": "",
 "msg": "MODULE FAILURE"
}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NameError: name 'false' is not defined
dell201srv | FAILED! => {
 "changed": false,
 "failed": true,
 "module_stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nNameError: name 'false' is not defined\n",
 "module_stdout": "",
 "msg": "MODULE FAILURE"
}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NameError: name 'false' is not defined
dell190srv | FAILED! => {
 "changed": false,
 "failed": true,
 "module_stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nNameError: name 'false' is not defined\n",
 "module_stdout": "",
 "msg": "MODULE FAILURE"
}
dell027srv | UNREACHABLE! => {
 "changed": false,
 "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh",
 "unreachable": true
}

1. 
1. this is really annoying as it is blocking my progress in learning this tool, i am in the middle of the course and i like it.

   Please can anyone help me and tell me what is missing, why i am not able to connect to these machines, and what is the best way to do so?

   i have been searching for one week for a solution and still no success.

   waiting for your help, Thanks in advance!

   Regards,

   Anthony

1. 

```

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [May 2, 2017, 7:09pm UTC](https://forum.ansible.com/t/python-annoying-error-when-connecting-to-target-machines/24381/2 "2017-05-02T19:09:34Z")

</div>

It looks like your install of Python isn't complete, or you're missing  
some required env.  
vars.

Back to your UNIX team?

---

<div class="post-metadata">

**Author:** ![Anthony\_Youssef](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Anthony\_Youssef](https://forum.ansible.com/u/Anthony_Youssef)\
**Post date:** [May 3, 2017, 6:02am UTC](https://forum.ansible.com/t/python-annoying-error-when-connecting-to-target-machines/24381/3 "2017-05-03T06:02:50Z")

</div>

Hi,

yeah, but is it possible to execute ansible on remote hosts using python located on a shared location , python should be installed on these remote hosts?  
I am asking thia to prevent install python on this big number of machines…
