Ubuntu Natty: Fixing "unknown locale" in Python

The fix itself is the same as for Python 2.5 – only the line numbers have changed. Open the file /usr/lib/python2.7/locale.py and find the line containing en_gb (line 921) and add these lines (this works for Danish locales): 'en_dk': 'en_DK.ISO8859-1', 'en_dk.iso88591': 'en_DK.ISO8859-1', 'en_dk@euro': 'en_DK.ISO8859-15', In order to avoid this change getting overwritten by packages updates, I use dpkg-divert: $ sudo dpkg-divert --add --rename --divert /usr/lib/python2.7/locale.py.real /usr/lib/python2.7/locale.py $ sudo cp /usr/lib/python2....

June 27, 2011 · 1 min · alj

Fixing Python's "unknown locale"

One problem I run into every time I upgrade Python or install a new Ubuntu computer is this (caused by me running locale en_DK) raise ValueError, 'unknown locale: %s' % localename ValueError: unknown locale: en_DK I am not an Python expert (not even remotely) so I used some time looking for some sort of fix for this problem. Open the file /usr/lib/python2.5/locale.py and find the line containing en_gb (around line 760) and then add this above:...

August 17, 2008 · 1 min · alj