1

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

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

我也执行了brew linkapps python

我已经使用安装了电力线状态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

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

在 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)
4

1 回答 1

5

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

export LC_ALL=en_US.UTF-8 
export LANG=en_US.UTF-8
于 2015-07-27T05:50:26.847 回答