ValueError: unknown locale: UTF-8

Date posted : 07/06/2019

There are times when install some packages, you will end getting this error due to locale issue.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pheonix/webapp/lib/python2.7/site-  
packages/pandas/", line 39, in <module>
    from pandas.core.api import *
  File "/Users/pheonix/webapp/lib/python2.7/site-  packages/pandas/core/", line 10, in <module>
from pandas.core.groupby import Grouper
  File "/Users/pheonix/webapp/lib/python2.7/site-packages/pandas/core/", line 18, in <module>
    from pandas.core.frame import DataFrame
  File "/Users/pheonix/webapp/lib/python2.7/site-packages/pandas/core/", line 39, in <module>
    from pandas.core.series import Series
  File "/Users/pheonix/webapp/lib/python2.7/site-packages/pandas/core/", line 2944, in <module>
    import as _gfx  # noqa
  File "/Users/pheonix/webapp/lib/python2.7/site-packages/pandas/tools/", line 27, in <module>
    import pandas.tseries.converter as conv
  File "/Users/pheonix/webapp/lib/python2.7/site-   packages/pandas/tseries/", line 7, in <module>
    import matplotlib.units as units
  File "/Users/pheonix/webapp/lib/python2.7/site-packages/matplotlib/", line 1131, in <module>
    rcParams = rc_params()
  File "/Users/pheonix/webapp/lib/python2.7/site-  
packages/matplotlib/", line 975, in rc_params
    return rc_params_from_file(fname, fail_on_error)
  File "/Users/pheonix/webapp/lib/python2.7/site-packages/matplotlib/", line 1100, in rc_params_from_file
    config_from_file = _rc_params_in_file(fname, fail_on_error)
  File "/Users/pheonix/webapp/lib/python2.7/site-packages/matplotlib/", line 1018, in _rc_params_in_file
     with _open_file_or_url(fname) as fd:
  File "/Users/pheonix/webapp/lib/python2.7/", line 17, in __enter__
  File "/Users/pheonix/webapp/lib/python2.7/site-   packages/matplotlib/", line 1000, in _open_file_or_url
    encoding = locale.getdefaultlocale()[1]
  File "/Users/pheonix/webapp/lib/python2.7/", line 545, in getdefaultlocale
    return _parse_localename(localename)
  File "/Users/pheonix/webapp/lib/python2.7/", line 477, in   _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8


You need to add locale settings in environment file.

Open the file and append below lines.

 $ vim /etc/environment

Thanks for using pheonix solutions.

You find this tutorial helpful? Share with your friends to keep it alive.

Leave a Reply