Ubuntu – ‘unsupported locale setting’ fault by command-not-found


I recently installed Ubuntu 12.10 by keeping the home folders from Linux Mint 13 distribution. The system installed fine, but at the beginning everything was in Chinese (even the text in the Terminal). I managed to solve that by editing some files, but I still get an error whenever a command is not found in Terminal. Here it is:

Sorry, command-not-found has crashed! Please file a bug report at:
Please include the following information with the report:

command-not-found version: 0.3
Python version: 3.2.3 final 0
Distributor ID: Ubuntu
Description:    Ubuntu 12.10
Release:    12.10
Codename:   quantal
Exception information:

unsupported locale setting
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/CommandNotFound/util.py", line 24, in crash_guard
  File "/usr/lib/command-not-found", line 69, in main
  File "/usr/lib/command-not-found", line 40, in enable_i18n
locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.2/locale.py", line 541, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

How can I get rid of this error. It says that it is a locale error, so I guess it might be related to the initial language problem, but I'm not an expert in linux stuff. What is your opinion?

Best Answer

I had the same problem, but found the following solution over at ubuntuforums:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales