How to fix locale issue in Red Hat distro?

jcfaracco picture jcfaracco · Sep 12, 2014 · Viewed 8k times · Source

I'm having a strange problem today in my RHEL system. My python script is returning:

>>> locale.setlocale(locale.LC_ALL, '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/locale.py", line 513, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

WHen I run...

$ locale

The ouput is...

locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
...

I have been trying many suggestions but none of them solved my issue yet.

For example:

  • Reinstall glibc-common.
  • Export LC_ALL as environment variable into ~/.bashrc.
  • Change the file /etc/sysconfig/i18n'.
  • locale-gen does not exists in RHEL.

Does anyone has a good suggestion to solve my issue. Remembering that I'm using RHEL and not Ubuntu (there are many tutorials about locale issues and Ubuntu).

Answer

Anderson So picture Anderson So · Nov 18, 2015

Add this to your /etc/environment

LC_ALL=en_US.UTF-8

LC_CTYPE=en_US.UTF-8

Then logout and login to shell again and try executing your commands.