Fix “ValueError: unknown locale: UTF-8″ under Mac OS X 10.8 Mountain Lion

Today I was trying the Writing your first Django app tutorial, and when I run the syncdb command I got this error:

ValueError: unknown locale: UTF-8

The solution was really simple I just needed to export some variables in my bash enviroment. So I edited my .bash_profile file adding these lines:

export LANG="es_ES.UTF-8"
export LC_COLLATE="es_ES.UTF-8"
export LC_CTYPE="es_ES.UTF-8"
export LC_MESSAGES="es_ES.UTF-8"
export LC_MONETARY="es_ES.UTF-8"
export LC_NUMERIC="es_ES.UTF-8"
export LC_TIME="es_ES.UTF-8"
export LC_ALL=

where es_ES.UTF-8 should be your locale string. To test if it worked for you just reload the console and run this code:

python -c 'import locale; print(locale.getdefaultlocale());'

You should get something like this:

('es_ES', 'UTF8')
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: