在 Yosemite 上为 bash shell 设置电源线时出错

Art*_*san 1 bash .bash-profile osx-yosemite powerline

我想在bash 中使用powerline(不是zsh如果可能,),但我遇到了一些错误,以下是我已完成的步骤

我最近使用自制软件安装了python

我也执行了 brew linkapps python

我已经安装了powerline-statys使用pip install powerline-status

我已经扩展了我的~/.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
Run Code Online (Sandbox Code Playgroud)

我还使用它从https://github.com/powerline/fonts安装了修补字体install.sh

经过Opennig新标签iTerm2我面临这个错误,我认为这是关于蟒蛇,但我没有想法如何解决它,所以请大家帮忙

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
Run Code Online (Sandbox Code Playgroud)

我的环境

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)
Run Code Online (Sandbox Code Playgroud)

Yur*_* G. 5

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

export LC_ALL=en_US.UTF-8 
export LANG=en_US.UTF-8
Run Code Online (Sandbox Code Playgroud)