Sourabh Bajaj

About Blog GitHub

31 Mar 2014
Fix Value Error: unknown locale: UTF 8

Today I was trying to install AWS cli and got this error when running the help command.

raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

The solution was to add some environment variables to my zsh environment. So I added this to my env-config files.

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

To test the code run:

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

And you should see ('en_US', 'UTF-8') as the output.

References for the post:

About Blog GitHub