[AWS] AWS Linux のcliで 「unknown locale: UTF-8」のエラーが出る場合

AWS上のAWS Linuxのマシンテンプレートだと環境変数が LC_CTYPEがUTF-8になっています。この状態だと aws cli などのツールでエラーが表示されます。

$ aws
Traceback (most recent call last):
File "/usr/bin/aws", line 15, in <module>
import awscli.clidriver
File "/usr/lib/python2.6/site-packages/awscli/clidriver.py", line 31, in <module>
from awscli.help import ProviderHelpCommand
File "/usr/lib/python2.6/site-packages/awscli/help.py", line 20, in <module>
from docutils.core import publish_string
File "/usr/lib/python2.6/site-packages/docutils/core.py", line 20, in <module>
from docutils import frontend, io, utils, readers, writers
File "/usr/lib/python2.6/site-packages/docutils/frontend.py", line 41, in <module>
import docutils.utils
File "/usr/lib/python2.6/site-packages/docutils/utils/__init__.py", line 20, in <module>
import docutils.io
File "/usr/lib/python2.6/site-packages/docutils/io.py", line 18, in <module>
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
File "/usr/lib/python2.6/site-packages/docutils/utils/error_reporting.py", line 46, in <module>
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/usr/lib64/python2.6/locale.py", line 478, in getdefaultlocale
return _parse_localename(localename)
File "/usr/lib64/python2.6/locale.py", line 410, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

期待されるのは ja_JP.UTF-8 のような形式なので

$ export LC_ALL='ja_JP.UTF-8'

で定義するとエラーが出なくなります。

上部へスクロール