# \[WARNING\]: Unhandled error in Python interpreter....

**URL:** <https://forum.ansible.com/t/warning-unhandled-error-in-python-interpreter/34192>\
**Category:** Ansible Project\
**Created:** [November 12, 2020, 11:13pm UTC](https://forum.ansible.com/t/warning-unhandled-error-in-python-interpreter/34192 "2020-11-12T23:13:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bill\_paxton](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bill\_paxton](https://forum.ansible.com/u/bill_paxton)\
**Post date:** [November 12, 2020, 11:13pm UTC](https://forum.ansible.com/t/warning-unhandled-error-in-python-interpreter/34192/1 "2020-11-12T23:13:37Z")

</div>

I have a task that works fine for Ansible 2.9.7, but fails when I upgrade to 2.10.3.

```auto
yaml

- name: Ping ServiceNow IP Address
shell: "ping -c 1 -w 5 {{ sn_ip_address | trim }}"

ignore_errors: true
register: ping_result_sn_ip_address_raw
when: sn_ip_address | trim | ipv4
failed_when: false
changed_when: false
delegate_to: localhost

```

When the task is run with Ansible 2.10.3, I receive:

[WARNING]: Unhandled error in Python interpreter discovery for host  
some\_snow\_host: Failed to connect to the host via ssh: ssh: connect to host  
localhost port 22: Cannot assign requested address  
fatal: [some\_snow\_host]: UNREACHABLE! =\> {  
“changed”: false,  
“unreachable”: true  
}

MSG:

Data could not be sent to remote host “localhost”. Make sure this host can be reached over ssh: ssh: connect to host localhost port 22: Cannot assign requested address

**Note:** there are other tasks in the same playbook that use “delegate\_to: localhost” that work fine, although those tasks are not using the “shell” module.

---

<div class="post-metadata">

**Author:** ![bill\_paxton](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bill\_paxton](https://forum.ansible.com/u/bill_paxton)\
**Post date:** [November 13, 2020, 1:03am UTC](https://forum.ansible.com/t/warning-unhandled-error-in-python-interpreter/34192/2 "2020-11-13T01:03:22Z")

</div>

Update: I found that:

- 2.9.8, 2.9.9 also work as expected.
- 2.9.10, 2.9.12, 2.9.15 exhibit the same error as with 2.10.3  
Basically, I built my docker images with different Ansible versions until I found the “breaking point” between 2.9.9 and 2.9.10 🙂

I guess I’ll open an issue on the project, but if anybody has any input please feel free to respond.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [November 13, 2020, 8:32am UTC](https://forum.ansible.com/t/warning-unhandled-error-in-python-interpreter/34192/3 "2020-11-13T08:32:09Z")

</div>

> I have a task that works fine for Ansible 2.9.7, but fails when I upgrade  
> to 2.10.3.  
> ...  
> Data could not be sent to remote host "localhost". Make sure this host can  
> be reached over ssh: ssh: connect to host localhost port 22: Cannot assign  
> requested address

FWIW, I'm still on 2.9.6.

As a hint, try to find out why \*ssh\* connection plugin is used to  
connect localhost. IMHO, the default is \*local\*. For example, testing  
with no configuration of the connection ("cat hosts | grep  
connection" shows nothing)

&nbsp;&nbsp;\> cat pb.yml  
&nbsp;&nbsp;- hosts: test\_01  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var: ansible\_connection  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var: ansible\_connection  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: localhost

gives

&nbsp;&nbsp;TASK [debug] \*\*\*\*  
&nbsp;&nbsp;ok: [test\_01] =\>  
&nbsp;&nbsp;&nbsp;&nbsp;ansible\_connection: ssh

&nbsp;&nbsp;TASK [debug]\*\*\*\*  
&nbsp;&nbsp;ok: [test\_01 -\> localhost] =\>  
&nbsp;&nbsp;&nbsp;&nbsp;ansible\_connection: local

See DEFAULT\_TRANSPORT  
[https://docs.ansible.com/ansible/latest/reference\_appendices/config.html#default-transport](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-transport)

"man ansible" says

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-v, --verbose  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;verbose mode (-vvv for more, -vvvv to enable connection  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;debugging)

For example

&nbsp;&nbsp;\> ansible-playbook pb.yml -vvvv | grep connection  
&nbsp;&nbsp;connection: smart  
&nbsp;&nbsp;&nbsp;&nbsp;ansible\_connection: ssh  
&nbsp;&nbsp;&nbsp;&nbsp;ansible\_connection: local

---

<div class="post-metadata">

**Author:** ![bill\_paxton](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bill\_paxton](https://forum.ansible.com/u/bill_paxton)\
**Post date:** [November 18, 2020, 5:43pm UTC](https://forum.ansible.com/t/warning-unhandled-error-in-python-interpreter/34192/4 "2020-11-18T17:43:48Z")

</div>

Thank you. I did open an [ansible github issue](https://github.com/ansible/ansible/issues/72611) and subsequently closed it based on respondents there. Your comments above definitely helped. Seems 2.9.10 fixed “buggy behavior” that I was relying on by not explicitly using “connection: local”.
