不支持的区域设置

不支持的区域设置

本文介绍了pip install - locale.Error: 不支持的区域设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整的堆栈跟踪:

➜  ~ pip install virtualenv
Traceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.4/site-packages/pip/__init__.py", line 215, in main
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib64/python3.4/locale.py", line 592, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

在同一台服务器上,我用 python 2.7.x 成功运行了 pip install virtualenv.

On the same server, I successfully ran pip install virtualenv with python 2.7.x.

现在,我刚刚使用 curl https://bootstrap.pypa.io/get-pip.py | 安装了 python3.4 |python3.4.

➜  ~ pip --version
pip 8.1.1 from /usr/lib/python3.4/site-packages (python 3.4)

pip uninstall virtualenv 也抛出同样的错误

推荐答案

根本原因是:你的环境变量 LC_ALL 丢失或以某种方式无效

The root cause is: your environment variable LC_ALL is missing or invalid somehow

简短回答-

只需运行以下命令:

$ export LC_ALL=C

如果您在新的终端窗口中不断收到错误消息,请将其添加到 .bashrc 文件的底部.

If you keep getting the error in new terminal windows, add it at the bottom of your .bashrc file.

长答案-

这是我的 locale 设置:

$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C

Python2.7

    $ uname -a
    Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u6 (2015-11-09) x86_64 GNU/Linux
    $ python --version
    Python 2.7.9
    $ pip --version
    pip 8.1.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
    $ unset LC_ALL
    $ pip install virtualenv
    Traceback (most recent call last):
      File "/usr/local/bin/pip", line 11, in <module>
        sys.exit(main())
      File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 215, in main
        locale.setlocale(locale.LC_ALL, '')
      File "/usr/lib/python2.7/locale.py", line 579, in setlocale
        return _setlocale(category, locale)
    locale.Error: unsupported locale setting
    $ export LC_ALL=C
    $ pip install virtualenv
    Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/dist-packages

这篇关于pip install - locale.Error: 不支持的区域设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 10:17