2016年10月20日 星期四

locale.Error: unsupported locale setting

# openstack service create --name keystone --description "OpenStack Identity" identity

Traceback (most recent call last):
  File "/usr/bin/openstack", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/dist-packages/openstackclient/shell.py", line 342, in main
    return OpenStackShell().run(argv)
  File "/usr/lib/python2.7/dist-packages/openstackclient/shell.py", line 79, in __init__
    command_manager=commandmanager.CommandManager('openstack.cli'))
  File "/usr/lib/python2.7/dist-packages/cliff/app.py", line 74, in __init__
    self._set_streams(stdin, stdout, stderr)
  File "/usr/lib/python2.7/dist-packages/cliff/app.py", line 82, in _set_streams
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python2.7/locale.py", line 579, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting


List locale supported (installed) by current system:
locale -a
Or install the locale by:
sudo apt-get install language-pack-id
Re-generate the locale:
sudo dpkg-reconfigure locales
If I set LC_ALL to something not installed, I got
warning: setlocale: LC_ALL: cannot change locale (zh_TW.UTF-8)
If the LC_ALL is empty:
# sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "",
        LC_ALL = "",
        LC_PAPER = "zh_TW.UTF-8",
        LC_ADDRESS = "zh_TW.UTF-8",
        LC_MONETARY = "zh_TW.UTF-8",
        LC_NUMERIC = "zh_TW.UTF-8",
        LC_TELEPHONE = "zh_TW.UTF-8",
        LC_IDENTIFICATION = "zh_TW.UTF-8",
        LC_MEASUREMENT = "zh_TW.UTF-8",
        LC_TIME = "zh_TW.UTF-8",
        LC_NAME = "zh_TW.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales...
  en_AG.UTF-8... up-to-date
  en_AU.UTF-8... up-to-date
  en_BW.UTF-8... up-to-date
  en_CA.UTF-8... up-to-date
  en_DK.UTF-8... up-to-date
  en_GB.UTF-8... up-to-date
  en_HK.UTF-8... up-to-date
  en_IE.UTF-8... up-to-date
  en_IN.UTF-8... up-to-date
  en_NG.UTF-8... up-to-date
  en_NZ.UTF-8... up-to-date
  en_PH.UTF-8... up-to-date
  en_SG.UTF-8... up-to-date
  en_US.UTF-8... up-to-date
  en_ZA.UTF-8... up-to-date
  en_ZM.UTF-8... up-to-date
  en_ZW.UTF-8... up-to-date
Generation complete.
In my case, my LC_ALL is empty. Setting it to something installed fix the issue:
export LC_ALL=en_US.UTF-8
export LC_ALL='C'


export LC_ALL='zh_TW.UTF-8'
export LC_ALL=''

沒有留言: