Yosemite bash shell 的电力线设置错误

Error setup powerline for bash shell on Yosemite

我想将 powerlinebash 一起使用(不是 zsh如果可能的话)但我遇到了一些错误,以下是我完成的步骤

我最近使用 homebrew

安装了 python

我也执行过brew linkapps python

我已经使用 pip install powerline-status

安装了 powerline-statys

我扩展了我的 ~/.bash_profile

if [ -f /usr/local/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh ]; then
    source /usr/local/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh
fi

我还使用 install.sh

安装了 https://github.com/powerline/fonts 的补丁字体

iTerm2 中打开新标签后我遇到了这个错误,我认为是关于 python 但我没有关于如何修复它的想法,所以请帮助

traceback (most recent call last):
  File "/usr/local/bin/powerline-config", line 6, in <module>
    from powerline.commands.config import get_argparser
  File "/usr/local/lib/python2.7/site-packages/powerline/commands/config.py", line 6, in <module>
    import powerline.bindings.config as config
  File "/usr/local/lib/python2.7/site-packages/powerline/bindings/config.py", line 19, in <module>
    from powerline.commands.main import finish_args
  File "/usr/local/lib/python2.7/site-packages/powerline/commands/main.py", line 17, in <module>
    encoding = get_preferred_arguments_encoding()
  File "/usr/local/lib/python2.7/site-packages/powerline/lib/encoding.py", line 77, in get_preferred_arguments_encoding
    locale.getdefaultlocale()[1]
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 543, in getdefaultlocale
   return _parse_localename(localename)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
Traceback (most recent call last):
  File "/usr/local/bin/powerline-config", line 6, in <module>
    from powerline.commands.config import get_argparser
  File "/usr/local/lib/python2.7/site-packages/powerline/commands/config.py", line 6, in <module>
    import powerline.bindings.config as config
  File "/usr/local/lib/python2.7/site-packages/powerline/bindings/config.py", line 19, in <module>
    from powerline.commands.main import finish_args
  File "/usr/local/lib/python2.7/site-packages/powerline/commands/main.py", line 17, in <module>
    encoding = get_preferred_arguments_encoding()
  File "/usr/local/lib/python2.7/site-packages/powerline/lib/encoding.py", line 77, in get_preferred_arguments_encoding
    locale.getdefaultlocale()[1]
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 543, in getdefaultlocale
    return _parse_localename(localename)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

我的环境

python --version
Python 2.7.6

brew list python
/usr/local/Cellar/python/2.7.10_2/bin/2to3
/usr/local/Cellar/python/2.7.10_2/bin/2to3-2
/usr/local/Cellar/python/2.7.10_2/bin/2to3-2.7
/usr/local/Cellar/python/2.7.10_2/bin/easy_install
/usr/local/Cellar/python/2.7.10_2/bin/easy_install-2.7
/usr/local/Cellar/python/2.7.10_2/bin/idle
/usr/local/Cellar/python/2.7.10_2/bin/idle2
/usr/local/Cellar/python/2.7.10_2/bin/idle2.7
/usr/local/Cellar/python/2.7.10_2/bin/pip
/usr/local/Cellar/python/2.7.10_2/bin/pip2
/usr/local/Cellar/python/2.7.10_2/bin/pip2.7
/usr/local/Cellar/python/2.7.10_2/bin/pydoc
/usr/local/Cellar/python/2.7.10_2/bin/pydoc2
/usr/local/Cellar/python/2.7.10_2/bin/pydoc2.7
/usr/local/Cellar/python/2.7.10_2/bin/python
/usr/local/Cellar/python/2.7.10_2/bin/python-config
/usr/local/Cellar/python/2.7.10_2/bin/python2
/usr/local/Cellar/python/2.7.10_2/bin/python2-config
/usr/local/Cellar/python/2.7.10_2/bin/python2.7
/usr/local/Cellar/python/2.7.10_2/bin/python2.7-config
/usr/local/Cellar/python/2.7.10_2/bin/pythonw
/usr/local/Cellar/python/2.7.10_2/bin/pythonw2
/usr/local/Cellar/python/2.7.10_2/bin/pythonw2.7
/usr/local/Cellar/python/2.7.10_2/bin/smtpd.py
/usr/local/Cellar/python/2.7.10_2/bin/smtpd2.7.py
/usr/local/Cellar/python/2.7.10_2/bin/smtpd2.py
/usr/local/Cellar/python/2.7.10_2/bin/wheel
/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/ (3761 files)
/usr/local/Cellar/python/2.7.10_2/IDLE.app/Contents/ (8 files)
/usr/local/Cellar/python/2.7.10_2/lib/pkgconfig/ (3 files)
/usr/local/Cellar/python/2.7.10_2/libexec/pip/ (499 files)
/usr/local/Cellar/python/2.7.10_2/libexec/setuptools/ (227 files)
/usr/local/Cellar/python/2.7.10_2/libexec/wheel/ (92 files)
/usr/local/Cellar/python/2.7.10_2/Python Launcher.app/Contents/ (17 files)
/usr/local/Cellar/python/2.7.10_2/share/man/ (3 files)
/usr/local/Cellar/python/2.7.10_2/share/python/ (315 files)

您的 python 抱怨未知的语言环境 UTF-8。搜索网络给出以下 solution。将这些行添加到您的 ~/.bash_profile:

export LC_ALL=en_US.UTF-8 
export LANG=en_US.UTF-8