2016-03-17 68 views
0

我成功安裝了matplotlib和seaborn,但是,當我將它們導入python shell時,會發生許多錯誤。當我在OSX中導入matplotlib和seaborn時發生錯誤

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 

回答

1

您需要將以下兩行添加到您的~/.bash_profile然後鍵入source ~/.bash_profile或重新啓動終端:

export LC_ALL=en_US.UTF-8 
export LANG=en_US.UTF-8 
相關問題