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:
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).
One solution to fix this issue, first run the locale command to list the locales currently defined for your user account. To generate the missing locale and reconfigure locales, identify the name of your locale ( in my case de_DE. UTF-8 ), or use one another one that you prefer, such as en_US. UTF-8 .
To change the default language you do not need to restart or reinstall Red Hat Enterprise Linux 5. You can do this as root by running the language selection application. This can be accessed from the system menu by clicking System => Administration => Language or typing system-config-language from a terminal.
Open the settings by clicking the drop down on the top right of the window and selecting the settings icon. Once the settings are open, click Region & Language and select your desired options.
How to Set System Locale in Linux. If you want to change or set system local, use the update-locale program. The LANG variable allows you to set the locale for the entire system. The following command sets LANG to en_IN.UTF-8 and removes definitions for LANGUAGE. To configure a specific locale parameter, edit the appropriate variable.
Note that this article should also work on any operating systems based on RHEL 8. A locale is a set of basic system parameters that define things such as a user’s language, region and any special variant preferences that the user wants to see in their user interface.
By default, RHEL 7 systems accept locale environment variables from ssh clients. The following locale environment variables will (if passed by the ssh client) be set in the environment before any login scripts are ran: The above output is from sshd_config.
How to check locale changes. Log out of the current session - the locale is set when you login so any change happens at the next login. Verify any changes made using the locale command: If the locale isn't what you now expect it to be, you should verify that the steps above have been followed.
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.
In my case it was iTerm setting the locale variables automatically. I fixed it by going to the iTerm menu and then
Preferences ... > Profiles > "select your profile" > Terminal > uncheck "Set locale variables automatically"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With