我通过conda安装pandas安装了pandas,并在通过ipython jupyter notebook导入pandas库时仍然收到此错误。
我还尝试通过
检查版本不匹配print ('version:' + np.__version__)
并从此
跟踪sys.executable目录的路径sys.executable
for x in sys.path: print (x)
并拥有数据目录的正确路径。
from jupyter_core.paths import jupyter_data_dir
print(jupyter_data_dir())
ValueError Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/__init__.py in <module>()
42 import pandas.core.config_init
43
---> 44 from pandas.core.api import *
45 from pandas.sparse.api import *
46 from pandas.stats.api import *
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/api.py in <module>()
7 from pandas.core.common import isnull, notnull
8 from pandas.core.categorical import Categorical
----> 9 from pandas.core.groupby import Grouper
10 from pandas.core.format import set_eng_float_format
11 from pandas.core.index import Index, CategoricalIndex, Int64Index, Float64Index, MultiIndex
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/groupby.py in <module>()
15 from pandas.core.base import PandasObject
16 from pandas.core.categorical import Categorical
---> 17 from pandas.core.frame import DataFrame
18 from pandas.core.generic import NDFrame
19 from pandas.core.index import Index, MultiIndex, CategoricalIndex, _ensure_index
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in <module>()
39 create_block_manager_from_arrays,
40 create_block_manager_from_blocks)
---> 41 from pandas.core.series import Series
42 from pandas.core.categorical import Categorical
43 import pandas.computation.expressions as expressions
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/core/series.py in <module>()
2907 # Add plotting methods to Series
2908
-> 2909 import pandas.tools.plotting as _gfx
2910
2911 Series.plot = base.AccessorProperty(_gfx.SeriesPlotMethods, _gfx.SeriesPlotMethods)
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/tools/plotting.py in <module>()
26 from pandas.util.decorators import Appender
27 try: # mpl optional
---> 28 import pandas.tseries.converter as conv
29 conv.register() # needs to override so set_xlim works with str/number
30 except ImportError:
/Users/amitanshu/anaconda/lib/python3.5/site-packages/pandas/tseries/converter.py in <module>()
5 from dateutil.relativedelta import relativedelta
6
----> 7 import matplotlib.units as units
8 import matplotlib.dates as dates
9
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in <module>()
1129
1130 # this is the instance used by the matplotlib classes
-> 1131 rcParams = rc_params()
1132
1133 if rcParams['examples.directory']:
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in rc_params(fail_on_error)
973 return ret
974
--> 975 return rc_params_from_file(fname, fail_on_error)
976
977
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in rc_params_from_file(fname, fail_on_error, use_default_template)
1098 parameters specified in the file. (Useful for updating dicts.)
1099 """
-> 1100 config_from_file = _rc_params_in_file(fname, fail_on_error)
1101
1102 if not use_default_template:
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in _rc_params_in_file(fname, fail_on_error)
1016 cnt = 0
1017 rc_temp = {}
-> 1018 with _open_file_or_url(fname) as fd:
1019 try:
1020 for line in fd:
/Users/amitanshu/anaconda/lib/python3.5/contextlib.py in __enter__(self)
57 def __enter__(self):
58 try:
---> 59 return next(self.gen)
60 except StopIteration:
61 raise RuntimeError("generator didn't yield") from None
/Users/amitanshu/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in _open_file_or_url(fname)
998 else:
999 fname = os.path.expanduser(fname)
-> 1000 encoding = locale.getdefaultlocale()[1]
1001 if encoding is None:
1002 encoding = "utf-8"
/Users/amitanshu/anaconda/lib/python3.5/locale.py in getdefaultlocale(envvars)
557 else:
558 localename = 'C'
--> 559 return _parse_localename(localename)
560
561
/Users/amitanshu/anaconda/lib/python3.5/locale.py in _parse_localename(localename)
485 elif code == 'C':
486 return None, None
--> 487 raise ValueError('unknown locale: %s' % localename)
488
489 def _build_localename(localetuple):
ValueError: unknown locale: UTF-8
答案 0 :(得分:1)
尝试将以下参数添加到~/.bash_profile
(通过在terminal
中键入以下内容):
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8