MacOS上的Python 2.7:Matplotlib导致ValueError:未知区域设置:UTF-8

MacOS上的Python 2.7:Matplotlib导致ValueError:未知区域设置:UTF-8,python,macos,matplotlib,Python,Macos,Matplotlib,我在运行El Capitan MacOS 10.11.3 我对Matplotlib有问题 下面是导入Matplotlib的代码段,我在Chrome的jupyter笔记本中执行该代码 #These are all the modules we'll be using later. Make sure you can import them # before proceeding further. from __future__ import print_function import matplo

我在运行El Capitan MacOS 10.11.3 我对Matplotlib有问题

下面是导入Matplotlib的代码段,我在Chrome的jupyter笔记本中执行该代码

#These are all the modules we'll be using later. Make sure you can import them
# before proceeding further.
from __future__ import print_function
import matplotlib.pyplot as plt
给出(长)错误消息


看起来效果不错

$ pip install matplotlib

Requirement already satisfied (use --upgrade to upgrade): matplotlib in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pytz in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): cycler in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): pyparsing!=2.0.0,!=2.0.4,>=1.5.6 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from matplotlib)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/six-1.10.0-py2.7.egg (from python-dateutil->matplotlib)
怎么了?

谢谢

这是未知的区域设置错误。在
~/.bash\u配置文件中添加以下行:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
同时在终端中运行此命令以重新加载文件

source ~/.bash_profile

非常感谢你,你救了我的命,你是个天才
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
source ~/.bash_profile