Issue
I'm not sure if this a good place to ask for help with this error. Somehow I seem not to have a locale on my Debian Linux system. Basically, I became aware of this when a python program I was trying to run executed the line locale.setlocale(locale.LC_ALL, 'en_US')
. I get the error:
Traceback (most recent call last):
File "", line 1, in
File "runserver.py", line 4, in
site = TarbellSite(os.path.dirname(os.path.abspath(file)))
File "/home/brian/.virtualenvs/tarbell/src/flask-tarbell/tarbell/app.py", line 36, in init
self.projects = self.load_projects()
File "/home/brian/.virtualenvs/tarbell/src/flask-tarbell/tarbell/app.py", line 59, in load_projects
project = imp.load_module(name, filename, pathname, description)
File "/home/brian/Code/contrib/tarbell/base/config.py", line 28, in
locale.setlocale(locale.LC_ALL, 'en_US')
File "/home/brian/.virtualenvs/tarbell/lib/python2.7/locale.py", line 547, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
However, researching relevant extant questions on SO like this one, tells me to run locale -a
, which yields:
C
C.UTF-8
en_US.utf8
POSIX
So, it looks like US english IS in the locales on my system. What am I doing wrong? I am running into various other road blocks. sudo apt-get install language-pack-en
according to a lot of places on the internet gets the english language pack. But apt complains that this package doesn't exist. How do I get this damn locale?
Solution
try to add the 'utf8' bit as well;
import locale
locale.getlocale()
>>> (None, None)
locale.setlocale(locale.LC_ALL, 'en_US.utf8')
>>> 'en_US.utf8'
locale.getlocale()
>>> ('en_US', 'UTF-8')
Answered By - SunPowered