# msg = unicode(msg).encode('utf8') LookupError

**URL:** <https://forum.ansible.com/t/msg-unicode-msg-encode-utf8-lookuperror/15517>\
**Category:** Ansible Project\
**Created:** [June 20, 2014, 9:28pm UTC](https://forum.ansible.com/t/msg-unicode-msg-encode-utf8-lookuperror/15517 "2014-06-20T21:28:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nic\_Flores](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@Nic\_Flores](https://forum.ansible.com/u/Nic_Flores)\
**Post date:** [June 20, 2014, 9:28pm UTC](https://forum.ansible.com/t/msg-unicode-msg-encode-utf8-lookuperror/15517/1 "2014-06-20T21:28:48Z")

</div>

Hi All,

I’m seeing the following error:

When I run the following command:

ansible my\_server -i sdc\_hosts -m ping -u ansible --ask-pass

against a server running:

myserver$ python --version  
Python 2.6.6

myserver | FAILED \>\> {  
“failed”: true,  
“msg”: “Traceback (most recent call last):\n File "/home/ansible/.ansible/tmp/ansible-tmp-1403299259.38-79129513838413/command", line 1383, in \n main()\n File "/home/ansible/.ansible/tmp/ansible-tmp-1403299259.38-79129513838413/command", line 91, in main\n module = CommandModule(argument\_spec=dict())\n File "/home/ansible/.ansible/tmp/ansible-tmp-1403299259.38-79129513838413/command", line 382, in **init** \n self.\_log\_invocation()\n File "/home/ansible/.ansible/tmp/ansible-tmp-1403299259.38-79129513838413/command", line 974, in \_log\_invocation\n msg = unicode(msg).encode(‘utf8’)\nLookupError: no codec search functions registered: can’t find encoding\n”,  
“parsed”: false  
}

Does anyone have an idea as to what my be causing this?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [June 20, 2014, 9:31pm UTC](https://forum.ansible.com/t/msg-unicode-msg-encode-utf8-lookuperror/15517/2 "2014-06-20T21:31:14Z")

</div>

Hi Nick,

Can we get a quick check of what “ansible --version” says?

---

<div class="post-metadata">

**Author:** ![Nic\_Flores](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@Nic\_Flores](https://forum.ansible.com/u/Nic_Flores)\
**Post date:** [June 20, 2014, 9:54pm UTC](https://forum.ansible.com/t/msg-unicode-msg-encode-utf8-lookuperror/15517/3 "2014-06-20T21:54:29Z")

</div>

Here you go:

ansible 1.6 (devel a37a84243b) last updated 2014/04/16 17:45:50 (GMT +000)

Nic

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [June 21, 2014, 4:49pm UTC](https://forum.ansible.com/t/msg-unicode-msg-encode-utf8-lookuperror/15517/4 "2014-06-21T16:49:04Z")

</div>

You’re three dot releases back - see if this occurs in 1.6.3 if you don’t mind - and file a bug if it does.

---

<div class="post-metadata">

**Author:** ![Nic\_Flores](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@Nic\_Flores](https://forum.ansible.com/u/Nic_Flores)\
**Post date:** [June 23, 2014, 8:52pm UTC](https://forum.ansible.com/t/msg-unicode-msg-encode-utf8-lookuperror/15517/5 "2014-06-23T20:52:31Z")

</div>

I just did a git clone and I am now running the following version of ansible

-bash-4.1$ ansible --version  
ansible 1.7 (devel f8bf9cdeec) last updated 2014/06/23 20:27:32 (GMT +000):

and now I get a different error:

-bash-4.1$ ansible myserver -i …/inventory/hosts -m ping -u ansible --ask-pass  
SSH password:

my server | FAILED \>\> {  
“failed”: true,  
“msg”: “Traceback (most recent call last):\n File "/home/ansible/.ansible/tmp/ansible-tmp-1403556652.28-139660901347999/ping", line 97, in \n import locale\n File "/usr/lib64/python2.6/locale.py", line 14, in \nImportError: No module named encodings\n”,  
“parsed”: false  
}

any thoughts?

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [June 24, 2014, 1:34pm UTC](https://forum.ansible.com/t/msg-unicode-msg-encode-utf8-lookuperror/15517/6 "2014-06-24T13:34:13Z")

</div>

The exception you’re seeing is coming from inside a python-distributed package, so this would seem to be a python pathing problem. Do you have multiple versions of python installed, and/or did you install python from source?

---

<div class="post-metadata">

**Author:** ![Nic\_Flores](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@Nic\_Flores](https://forum.ansible.com/u/Nic_Flores)\
**Post date:** [June 25, 2014, 6:53pm UTC](https://forum.ansible.com/t/msg-unicode-msg-encode-utf8-lookuperror/15517/7 "2014-06-25T18:53:16Z")

</div>

James,  
Thanks for pinning this down for me. I’ll look into how python was installed on the server. At least now I know the problem is now on the server side and not on the ansible side.
