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

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?

Hi Nick,

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

Here you go:

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

Nic

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.

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?

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?

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.