MacOS X: ValueError: unknown locale: UTF-8 (Fixed)
Dec 7, 2016 15:16 · 58 words · 1 minute read
This typically occurs on MacOS X when executing Python scripts:
File "/Users/millerc/anaconda/lib/python2.7/locale.py", line 503, in getdefaultlocale
return _parse_localename(localename)
File "/Users/millerc/anaconda/lib/python2.7/locale.py", line 435, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
Solution:
Edit ~/.bash_profile
(in case of zsh
edit ~/.zshenv
) as follows:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Reload the profile with command below:
source ~/.bash_profile