python pandas和matplotlib安装冲突[重复]

Posted

技术标签:

【中文标题】python pandas和matplotlib安装冲突[重复]【英文标题】:python pandas and matplotlib installation conflict [duplicate] 【发布时间】:2016-04-30 02:07:12 【问题描述】:

我正在使用 Mac OSX Yosemite 10.10.5,我正在尝试在笔记本电脑上使用 python 练习数据科学。我在 virtualenv 上使用 python 3.5.1,但是当我安装 pandas 和 matplotlib 时,它们似乎在尝试导入时都存在冲突。两者都有相同的错误,输出是:

>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/deanarmada/.virtualenvs/python3-data-science/lib/python3.5/site-packages/matplotlib/__init__.py", line 1131, in <module>
    rcParams = rc_params()
  File "/Users/deanarmada/.virtualenvs/python3-data-science/lib/python3.5/site-packages/matplotlib/__init__.py", line 975, in rc_params
    return rc_params_from_file(fname, fail_on_error)
  File "/Users/deanarmada/.virtualenvs/python3-data-science/lib/python3.5/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/deanarmada/.virtualenvs/python3-data-science/lib/python3.5/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file
    with _open_file_or_url(fname) as fd:
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/Users/deanarmada/.virtualenvs/python3-data-science/lib/python3.5/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url
    encoding = locale.getdefaultlocale()[1]
  File "/Users/deanarmada/.virtualenvs/python3-data-science/lib/python3.5/locale.py", line 559, in getdefaultlocale
    return _parse_localename(localename)
  File "/Users/deanarmada/.virtualenvs/python3-data-science/lib/python3.5/locale.py", line 487, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8

【问题讨论】:

【参考方案1】:

只要运行:

export LC_ALL=C

在通过终端访问python之前。

【讨论】:

【参考方案2】:

我自己的问题的完美答案是

添加: 导出 LC_ALL=C 导出 LANG=en_US.UTF-8

在你身上~/.bash_profile

退出您的终端,然后重新开始,然后您现在可以尝试导入所有内容

【讨论】:

以上是关于python pandas和matplotlib安装冲突[重复]的主要内容,如果未能解决你的问题,请参考以下文章

Python中Pandas/Matplotlib中直方图和密度的叠加

安装Matplotlib

Python图形绘制:如何用Matplotlib和pandas绘图?

python-数据处理的包Numpy,scipy,pandas,matplotlib

python-[panda]-[sklearn]-[matplotlib]-线性预测

Panda和numpy库和matplotlib库的安装