0

I installed the matplotlib and seaborn successfully, however, when I import them in the python shell, many errors occur.

Python 2.7.11 |Anaconda 2.5.0 (x86_64)| (default, Dec  6 2015, 18:57:58) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 1131, in <module>
    rcParams = rc_params()
  File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 975, in rc_params
    return rc_params_from_file(fname, fail_on_error)
  File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 1100, in rc_params_from_file
    config_from_file = _rc_params_in_file(fname, fail_on_error)
  File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file
    with _open_file_or_url(fname) as fd:
  File "/Users/guanqingliang/anaconda/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url
    encoding = locale.getdefaultlocale()[1]
  File "/Users/guanqingliang/anaconda/lib/python2.7/locale.py", line 543, in getdefaultlocale
    return _parse_localename(localename)
  File "/Users/guanqingliang/anaconda/lib/py`enter code here`thon2.7/locale.py", line 475, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
Pep_8_Guardiola
  • 5,002
  • 1
  • 24
  • 35

1 Answers1

1

You need to add the following two lines to your ~/.bash_profile and then type source ~/.bash_profile or restart the terminal:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284